home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / doc / libslang2 / slangfun.txt < prev    next >
Encoding:
Text File  |  2009-12-05  |  246.7 KB  |  9,915 lines

  1. all
  2.  
  3.  SYNOPSIS
  4.   Tests if all elements of an array are non-zero
  5.  
  6.  USAGE
  7.   Char_Type all (Array_Type a [,Int_Type dim])
  8.  
  9.  DESCRIPTION
  10.   The `all' function examines the elements of a numeric array and
  11.   returns 1 if all elements are non-zero, otherwise it returns 0. If a
  12.   second argument is given, then it specifies the dimension of the
  13.   array over which the function is to be applied.  In this case, the
  14.   result will be an array with the same shape as the input array minus
  15.   the specified dimension.
  16.  
  17.  EXAMPLE
  18.   Consider the 2-d array
  19.  
  20.       1       2       3       4        5
  21.       6       7       8       9       10
  22.  
  23.   generated by
  24.  
  25.       a = _reshape ([1:10], [2, 5]);
  26.  
  27.   Then `all(a)' will return 1, and `all(a>3, 0)' will return
  28.   a 1-d array
  29.  
  30.       [0, 0, 0, 1, 1]
  31.  
  32.   Similarly, `all(a>3, 1)' will return the 1-d array
  33.  
  34.       [0,1]
  35.  
  36.  
  37.  SEE ALSO
  38.   where, any
  39.  
  40. --------------------------------------------------------------
  41.  
  42. any
  43.  
  44.  SYNOPSIS
  45.   Test if any element of an array is non-zero
  46.  
  47.  USAGE
  48.   Char_Type any (Array_Type a [,Int_Type dim])
  49.  
  50.  DESCRIPTION
  51.   The `any' function examines the elements of a numeric array and
  52.   returns 1 if any element is both non-zero and not a NaN, otherwise
  53.   it returns 0.  If a second argument is given, then it specifies
  54.   the dimension of the array to be tested.
  55.  
  56.  EXAMPLE
  57.   Consider the 2-d array
  58.  
  59.       1       2       3       4        5
  60.       6       7       8       9       10
  61.  
  62.   generated by
  63.  
  64.       a = _reshape ([1:10], [2, 5]);
  65.  
  66.   Then `any(a==3)' will return 1, and `any(a==3, 0)'
  67.   will return a 1-d array with elements:
  68.  
  69.       0        0       1       0       0
  70.  
  71.  
  72.  SEE ALSO
  73.   where, all
  74.  
  75. --------------------------------------------------------------
  76.  
  77. array_info
  78.  
  79.  SYNOPSIS
  80.   Returns information about an array
  81.  
  82.  USAGE
  83.   (Array_Type, Integer_Type, DataType_Type) array_info (Array_Type a)
  84.  
  85.  DESCRIPTION
  86.   The `array_info' function returns information about the array `a'.
  87.   It returns three values: an 1-d integer array specifying the
  88.   size of each dimension of `a', the number of dimensions of
  89.   `a', and the data type of `a'.
  90.  
  91.  EXAMPLE
  92.   The `array_info' function may be used to find the number of rows
  93.   of an array:
  94.  
  95.     define num_rows (a)
  96.     {
  97.        variable dims, num_dims, data_type;
  98.  
  99.        (dims, num_dims, data_type) = array_info (a);
  100.        return dims [0];
  101.     }
  102.  
  103.  
  104.  SEE ALSO
  105.   typeof, array_shape, length, reshape, _reshape
  106.  
  107. --------------------------------------------------------------
  108.  
  109. array_map
  110.  
  111.  SYNOPSIS
  112.   Apply a function to each element of an array
  113.  
  114.  USAGE
  115.   Array_Type array_map (type, func, arg0, ...)
  116.  
  117.     DataType_Type type;
  118.     Ref_Type func;
  119.  
  120.  
  121.  DESCRIPTION
  122.   The `array_map' function may be used to apply a function to each
  123.   element of an array and returns the resulting values as an array of
  124.   the specified type.  The `type' parameter indicates what kind of
  125.   array should be returned and generally corresponds to the return
  126.   type of the function.  The `arg0' parameter should be an array
  127.   and is used to determine the dimensions of the resulting array.  If
  128.   any subsequent arguments correspond to an array of the same size,
  129.   then those array elements will be passed in parallel with the first
  130.   arrays arguments.
  131.  
  132.  EXAMPLE
  133.   The first example illustrates how to apply the `strlen' function
  134.   to an array of strings:
  135.  
  136.      S = ["", "Train", "Subway", "Car"];
  137.      L = array_map (Integer_Type, &strlen, S);
  138.  
  139.   This is equivalent to:
  140.  
  141.      S = ["", "Train", "Subway", "Car"];
  142.      L = Integer_Type [length (S)];
  143.      for (i = 0; i < length (S); i++) L[i] = strlen (S[i]);
  144.  
  145.  
  146.   Now consider an example involving the `strcat' function:
  147.  
  148.      files = ["slang", "slstring", "slarray"];
  149.  
  150.      exts = ".c";
  151.      cfiles = array_map (String_Type, &strcat, files, exts);
  152.      % ==> cfiles = ["slang.c", "slstring.c", "slarray.c"];
  153.  
  154.      exts =  [".a",".b",".c"];
  155.      xfiles = array_map (String_Type, &strcat, files, exts);
  156.      % ==> xfiles = ["slang.a", "slstring.b", "slarray.c"];
  157.  
  158.  
  159.  NOTES
  160.   Many mathematical functions already work transparantly on arrays.
  161.   For example, the following two statements produce identical results:
  162.  
  163.      B = sin (A);
  164.      B = array_map (Double_Type, &sin, A);
  165.  
  166.  
  167.  SEE ALSO
  168.   array_info, strlen, strcat, sin
  169.  
  170. --------------------------------------------------------------
  171.  
  172. array_reverse
  173.  
  174.  SYNOPSIS
  175.   Reverse the elements of an array
  176.  
  177.  USAGE
  178.   array_reverse (Array_Type a [,Int_Type i0, Int_Type i1] [,Int_Type dim])
  179.  
  180.  DESCRIPTION
  181.   In its simplest form, the `array_reverse' function reverses the
  182.   elements of an array.  If passed 2 or 4 arguments,
  183.   `array_reverse' reverses the elements of the specified
  184.   dimension of a multi-dimensional array.  If passed 3 or 4 arguments,
  185.   the parameters `i0' and `i1' specify a range of elements
  186.   to reverse.
  187.  
  188.  EXAMPLE
  189.   If `a' is a one dimensional array, then
  190.  
  191.     array_reverse (a, i, j);
  192.     a[[i:j]] = a[[j:i:-1]];
  193.  
  194.   are equivalent to one another.  However, the form using
  195.   `array_reverse' is about 10 times faster than the version that
  196.   uses explicit array indexing.
  197.  
  198.  SEE ALSO
  199.   array_swap, transpose
  200.  
  201. --------------------------------------------------------------
  202.  
  203. array_shape
  204.  
  205.  SYNOPSIS
  206.   Get the shape or dimensions of an array
  207.  
  208.  USAGE
  209.   dims = array_shape (Array_Type a)
  210.  
  211.  DESCRIPTION
  212.    This function returns an array representing the dimensionality or
  213.    shape of a specified array.  The `array_info' function also
  214.    returns this information but for many purposes the
  215.    `array_shape' function is more convenient.
  216.  
  217.  SEE ALSO
  218.   array_info, reshape
  219.  
  220. --------------------------------------------------------------
  221.  
  222. array_sort
  223.  
  224.  SYNOPSIS
  225.   Sort an array
  226.  
  227.  USAGE
  228.   Array_Type array_sort (Array_Type a [, String_Type or Ref_Type f])
  229.  
  230.  DESCRIPTION
  231.   `array_sort' sorts the array `a' into ascending order and
  232.   returns an integer array that represents the result of the sort. If
  233.   the optional second parameter `f' is present, the function
  234.   specified by `f' will be used to compare elements of `a';
  235.   otherwise, a built-in sorting function will be used.
  236.  
  237.   If `f' is present, then it must be either a string representing
  238.   the name of the comparison function, or a reference to the function.
  239.   The sort function represented by `f' must be a S-Lang function
  240.   that takes two arguments.  The function must return an integer that
  241.   is less than zero if the first parameter is considered to be less
  242.   than the second, zero if they are equal, and a value greater than
  243.   zero if the first is greater than the second.
  244.  
  245.   If the comparison function is not specified, then a built-in comparison
  246.   function appropriate for the data type will be used.  For example,
  247.   if `a' is an array of character strings, then the sort will be
  248.   performed using the `strcmp' function.
  249.  
  250.   The integer array returned by this function is simply an index array
  251.   that indicates the order of the sorted array.  The input array
  252.   `a' is not changed.
  253.  
  254.  EXAMPLE
  255.   An array of strings may be sorted using the `strcmp' function
  256.   since it fits the specification for the sorting function described
  257.   above:
  258.  
  259.      A = ["gamma", "alpha", "beta"];
  260.      I = array_sort (A, &strcmp);
  261.  
  262.   Alternatively, one may use
  263.  
  264.      variable I = array_sort (A);
  265.  
  266.   to use the built-in comparison function.
  267.  
  268.   After the `array_sort' has executed, the variable `I' will
  269.   have the values `[2, 0, 1]'.  This array can be used to
  270.   re-shuffle the elements of `A' into the sorted order via the
  271.   array index expression `A = A[I]'.  This operation may also be
  272.   written:
  273.  
  274.      A = A[array_sort(A)];
  275.  
  276.  
  277.  EXAMPLE
  278.   A homogeneous list may be sorted by first converting it to an array
  279.   as follows:
  280.  
  281.     list = list[ array_sort( list_to_array(list) ) ];
  282.  
  283.   Alternatively one may use
  284.  
  285.     a = list_to_array (list);
  286.     list[*] = a[array_sort(a)];
  287.  
  288.   to get the effect of an "in-place" sort.
  289.  
  290.  SEE ALSO
  291.   strcmp, list_to_array
  292.  
  293. --------------------------------------------------------------
  294.  
  295. array_swap
  296.  
  297.  SYNOPSIS
  298.   Swap elements of an array
  299.  
  300.  USAGE
  301.   array_swap (Array_Type a, Int_Type i, Int_Type j)
  302.  
  303.  DESCRIPTION
  304.   The `array_swap' function swaps the specified elements of an
  305.   array.  It is equivalent to
  306.  
  307.     (a[i], a[j]) = (a[j], a[i]);
  308.  
  309.   except that it executes several times faster than the above construct.
  310.  
  311.  SEE ALSO
  312.   array_reverse, transpose
  313.  
  314. --------------------------------------------------------------
  315.  
  316. cumsum
  317.  
  318.  SYNOPSIS
  319.   Compute the cumulative sum of an array
  320.  
  321.  USAGE
  322.   result = cumsum (Array_Type a [, Int_Type dim])
  323.  
  324.  DESCRIPTION
  325.   The `cumsum' function performs a cumulative sum over the
  326.   elements of a numeric array and returns the result.  If a second
  327.   argument is given, then it specifies the dimension of the array to
  328.   be summed over.  For example, the cumulative sum of
  329.   `[1,2,3,4]', is the array `[1,1+2,1+2+3,1+2+3+4]', i.e.,
  330.   `[1,3,6,10]'.
  331.  
  332.  SEE ALSO
  333.   sum, sumsq
  334.  
  335. --------------------------------------------------------------
  336.  
  337. init_char_array
  338.  
  339.  SYNOPSIS
  340.   Initialize an array of characters
  341.  
  342.  USAGE
  343.   init_char_array (Array_Type a, String_Type s)
  344.  
  345.  DESCRIPTION
  346.   The `init_char_array' function may be used to initialize a
  347.   character array `a' by setting the elements of the array
  348.   `a' to the corresponding characters of the string `s'.
  349.  
  350.  EXAMPLE
  351.   The statements
  352.  
  353.      variable a = Char_Type [10];
  354.      init_char_array (a, "HelloWorld");
  355.  
  356.    creates an character array and initializes its elements to the
  357.    characters in the string `"HelloWorld"'.
  358.  
  359.  NOTES
  360.    The character array must be large enough to hold all the characters
  361.    of the initialization string.
  362.  
  363.  SEE ALSO
  364.   bstring_to_array, strlen, strcat
  365.  
  366. --------------------------------------------------------------
  367.  
  368. _isnull
  369.  
  370.  SYNOPSIS
  371.   Check an array for NULL elements
  372.  
  373.  USAGE
  374.   Char_Type[] = _isnull (a[])
  375.  
  376.  DESCRIPTION
  377.   This function may be used to test for the presence of NULL elements
  378.   of an array.   Specifically, it returns a Char_Type array of
  379.   with the same number of elements and dimensionality of the input
  380.   array.  If an element of the input array is NULL, then the
  381.   corresponding element of the output array will be set to 1,
  382.   otherwise it will be set to 0.
  383.  
  384.  EXAMPLE
  385.   Set all NULL elements of a string array `A' to the empty
  386.   string `""':
  387.  
  388.      A[where(_isnull(A))] = "";
  389.  
  390.  
  391.  NOTES
  392.   It is important to understand the difference between `A==NULL'
  393.   and `_isnull(A)'.  The latter tests all elements of `A'
  394.   against NULL, whereas the former only tests `A' itself.
  395.  
  396.  SEE ALSO
  397.   where, array_map
  398.  
  399. --------------------------------------------------------------
  400.  
  401. length
  402.  
  403.  SYNOPSIS
  404.   Get the length of an object
  405.  
  406.  USAGE
  407.   Integer_Type length (obj)
  408.  
  409.  DESCRIPTION
  410.   The `length' function may be used to get information about the
  411.   length of an object.  For simple scalar data-types, it returns 1.
  412.   For arrays, it returns the total number of elements of the array.
  413.  
  414.  NOTES
  415.   If `obj' is a string, `length' returns 1 because a
  416.   String_Type object is considered to be a scalar.  To get the
  417.   number of characters in a string, use the `strlen' function.
  418.  
  419.  SEE ALSO
  420.   array_info, array_shape, typeof, strlen
  421.  
  422. --------------------------------------------------------------
  423.  
  424. max
  425.  
  426.  SYNOPSIS
  427.   Get the maximum value of an array
  428.  
  429.  USAGE
  430.   result = max (Array_Type a [,Int_Type dim])
  431.  
  432.  DESCRIPTION
  433.   The `max' function examines the elements of a numeric array and
  434.   returns the value of the largest element.  If a second argument is
  435.   given, then it specifies the dimension of the array to be searched.
  436.   In this case, an array of dimension one less than that of the input array
  437.   will be returned with the corresponding elements in the specified
  438.   dimension replaced by the maximum value in that dimension.
  439.  
  440.  EXAMPLE
  441.   Consider the 2-d array
  442.  
  443.       1       2       3       4        5
  444.       6       7       8       9       10
  445.  
  446.   generated by
  447.  
  448.       a = _reshape ([1:10], [2, 5]);
  449.  
  450.   Then `max(a)' will return `10', and `max(a,0)' will return
  451.   a 1-d array with elements
  452.  
  453.       6       7       8       9       10
  454.  
  455.  
  456.  NOTES
  457.   This function ignores NaNs in the input array.
  458.  
  459.  SEE ALSO
  460.   min, maxabs, sum, reshape
  461.  
  462. --------------------------------------------------------------
  463.  
  464. maxabs
  465.  
  466.  SYNOPSIS
  467.   Get the maximum absolute value of an array
  468.  
  469.  USAGE
  470.   result = maxabs (Array_Type a [,Int_Type dim])
  471.  
  472.  DESCRIPTION
  473.   The `maxabs' function behaves like the `max' function
  474.   except that it returns the maximum absolute value of the array. That
  475.   is, `maxabs(x)' is equivalent to `max(abs(x)'. See the
  476.   documentation for the `max' function for more information.
  477.  
  478.  SEE ALSO
  479.   min, max, minabs
  480.  
  481. --------------------------------------------------------------
  482.  
  483. min
  484.  
  485.  SYNOPSIS
  486.   Get the minimum value of an array
  487.  
  488.  USAGE
  489.   result = min (Array_Type a [,Int_Type dim])
  490.  
  491.  DESCRIPTION
  492.   The `min' function examines the elements of a numeric array and
  493.   returns the value of the smallest element.  If a second argument is
  494.   given, then it specifies the dimension of the array to be searched.
  495.   In this case, an array of dimension one less than that of the input array
  496.   will be returned with the corresponding elements in the specified
  497.   dimension replaced by the minimum value in that dimension.
  498.  
  499.  EXAMPLE
  500.   Consider the 2-d array
  501.  
  502.       1       2       3       4       5
  503.       6       7       8       9       10
  504.  
  505.   generated by
  506.  
  507.       a = _reshape ([1:10], [2, 5]);
  508.  
  509.   Then `min(a)' will return `1', and `min(a,0)' will return
  510.   a 1-d array with elements
  511.  
  512.       1        2       3       4       5
  513.  
  514.  
  515.  NOTES
  516.   This function ignores NaNs in the input array.
  517.  
  518.  SEE ALSO
  519.   max, sum, reshape
  520.  
  521. --------------------------------------------------------------
  522.  
  523. minabs
  524.  
  525.  SYNOPSIS
  526.   Get the minimum absolute value of an array
  527.  
  528.  USAGE
  529.   result = minabs (Array_Type a [,Int_Type dim])
  530.  
  531.  DESCRIPTION
  532.   The `minabs' function behaves like the `min' function
  533.   except that it returns the minimum absolute value of the array. That
  534.   is, `minabs(x)' is equivalent to `min(abs(x)'. See the
  535.   documentation for the `min' function for more information.
  536.  
  537.  SEE ALSO
  538.   min, max, maxabs
  539.  
  540. --------------------------------------------------------------
  541.  
  542. _reshape
  543.  
  544.  SYNOPSIS
  545.   Copy an array to a new shape
  546.  
  547.  USAGE
  548.   Array_Type _reshape (Array_Type A, Array_Type I)
  549.  
  550.  DESCRIPTION
  551.   The `_reshape' function creates a copy of an array `A',
  552.   reshapes it to the form specified by `I' and returns the result.
  553.   The elements of `I' specify the new dimensions of the copy of
  554.   `A' and must be consistent with the number of elements `A'.
  555.  
  556.  EXAMPLE
  557.   If `A' is a `100' element 1-d array, a new 2-d array of
  558.   size `20' by `5' may be created from the elements of `A'
  559.   by
  560.  
  561.       B = _reshape (A, [20, 5]);
  562.  
  563.  
  564.  NOTES
  565.   The `reshape' function performs a similar function to
  566.   `_reshape'.  In fact, the `_reshape' function could have been
  567.   implemented via:
  568.  
  569.      define _reshape (a, i)
  570.      {
  571.         a = @a;     % Make a new copy
  572.         reshape (a, i);
  573.         return a;
  574.      }
  575.  
  576.  
  577.  SEE ALSO
  578.   reshape, array_shape, array_info
  579.  
  580. --------------------------------------------------------------
  581.  
  582. reshape
  583.  
  584.  SYNOPSIS
  585.   Reshape an array
  586.  
  587.  USAGE
  588.   reshape (Array_Type A, Array_Type I)
  589.  
  590.  DESCRIPTION
  591.   The `reshape' function changes the shape of `A' to have the
  592.   shape specified by the 1-d integer array `I'.  The elements of `I'
  593.   specify the new dimensions of `A' and must be consistent with
  594.   the number of elements `A'.
  595.  
  596.  EXAMPLE
  597.   If `A' is a `100' element 1-d array, it can be changed to a
  598.   2-d `20' by `5' array via
  599.  
  600.       reshape (A, [20, 5]);
  601.  
  602.   However, `reshape(A, [11,5])' will result in an error because
  603.   the `[11,5]' array specifies `55' elements.
  604.  
  605.  NOTES
  606.   Since `reshape' modifies the shape of an array, and arrays are
  607.   treated as references, then all references to the array will
  608.   reference the new shape.  If this effect is unwanted, then use the
  609.   `_reshape' function instead.
  610.  
  611.  SEE ALSO
  612.   _reshape, array_info, array_shape
  613.  
  614. --------------------------------------------------------------
  615.  
  616. sum
  617.  
  618.  SYNOPSIS
  619.   Sum over the elements of an array
  620.  
  621.  USAGE
  622.   result = sum (Array_Type a [, Int_Type dim])
  623.  
  624.  DESCRIPTION
  625.   The `sum' function sums over the elements of a numeric array and
  626.   returns its result.  If a second argument is given, then it
  627.   specifies the dimension of the array to be summed over.  In this
  628.   case, an array of dimension one less than that of the input array
  629.   will be returned.
  630.  
  631.   If the input array is an integer type, then the resulting value will
  632.   be a Double_Type.  If the input array is a Float_Type,
  633.   then the result will be a Float_Type.
  634.  
  635.  EXAMPLE
  636.   The mean of an array `a' of numbers is
  637.  
  638.     sum(a)/length(a)
  639.  
  640.  
  641.  SEE ALSO
  642.   cumsum, sumsq, transpose, reshape
  643.  
  644. --------------------------------------------------------------
  645.  
  646. sumsq
  647.  
  648.  SYNOPSIS
  649.   Sum over the squares of the elements of an array
  650.  
  651.  USAGE
  652.   result = sumsq (Array_Type a [, Int_Type dim])
  653.  
  654.  DESCRIPTION
  655.   The `sumsq' function sums over the squares of the elements of a
  656.   numeric array and returns its result.  If a second argument is
  657.   given, then it specifies the dimension of the array to be summed
  658.   over.  In this case, an array of dimension one less than that of the
  659.   input array will be returned.
  660.  
  661.   If the input array is an integer type, then the resulting value will
  662.   be a Double_Type.  If the input array is a Float_Type,
  663.   then the result will be a Float_Type.
  664.  
  665.   For complex arrays, the sum will be over the squares of the moduli of
  666.   the complex elements.
  667.  
  668.  SEE ALSO
  669.   cumsum, sumsq, hypot, transpose, reshape
  670.  
  671. --------------------------------------------------------------
  672.  
  673. transpose
  674.  
  675.  SYNOPSIS
  676.   Transpose an array
  677.  
  678.  USAGE
  679.   Array_Type transpose (Array_Type a)
  680.  
  681.  DESCRIPTION
  682.   The `transpose' function returns the transpose of a specified
  683.   array.  By definition, the transpose of an array, say one with
  684.   elements `a[i,j,...k]' is an array whose elements are
  685.   `a[k,...,j,i]'.
  686.  
  687.  SEE ALSO
  688.   _reshape, reshape, sum, array_info, array_shape
  689.  
  690. --------------------------------------------------------------
  691.  
  692. where
  693.  
  694.  USAGE
  695.   Array_Type where (Array_Type a [, Ref_Type jp])
  696.  
  697.  DESCRIPTION
  698.   The `where' function examines a numeric array `a' and
  699.   returns an integer array giving the indices of `a'
  700.   where the corresponding element of `a' is non-zero.  The
  701.   function accepts an optional Ref_Type argument that will be
  702.   set to complement set of indices, that is, the indices where
  703.   `a' is zero.  In fact
  704.  
  705.      i = where (a);
  706.      j = where (not a);
  707.  
  708.   and
  709.  
  710.      i = where (a, &j);
  711.  
  712.   are equivalent, but the latter form is prefered since it executes
  713.   about twice as fast as the former.
  714.  
  715.   Although this function may appear to be simple or even trivial, it
  716.   is arguably one of the most important and powerful functions for
  717.   manipulating arrays.
  718.  
  719.  EXAMPLE
  720.   Consider the following:
  721.  
  722.     variable X = [0.0:10.0:0.01];
  723.     variable A = sin (X);
  724.     variable I = where (A < 0.0);
  725.     A[I] = cos (X) [I];
  726.  
  727.   Here the variable `X' has been assigned an array of doubles
  728.   whose elements range from `0.0' through `10.0' in
  729.   increments of `0.01'.  The second statement assigns `A' to
  730.   an array whose elements are the `sin' of the elements of `X'.
  731.   The third statement uses the `where' function to get the indices of
  732.   the elements of `A' that are less than 0.  Finally, the
  733.   last statement replaces those elements of `A' by the cosine of the
  734.   corresponding elements of `X'.
  735.  
  736.  NOTES
  737.   Support for the optional argument was added to version 2.1.0.
  738.  
  739.  SEE ALSO
  740.   wherefirst, wherelast, wherenot, array_info, array_shape, _isnull
  741.  
  742. --------------------------------------------------------------
  743.  
  744. wherenot
  745.  
  746.  SYNOPSIS
  747.   Get indices where a numeric array is 0
  748.  
  749.  USAGE
  750.   Array_Type wherenot (Array_Type)
  751.  
  752.  DESCRIPTION
  753.   This function is equivalent to `where(not a)'.  See the
  754.   documentation for `where' for more information.
  755.  
  756.  SEE ALSO
  757.   where, wherefirst, wherelast
  758.  
  759. --------------------------------------------------------------
  760.  
  761. wherefirst
  762.  
  763.  SYNOPSIS
  764.   Get the index of the first non-zero array element
  765.  
  766.  USAGE
  767.   Int_Type wherefirst (Array_Type a [,start_index])
  768.  
  769.  DESCRIPTION
  770.   The `wherefirst' function returns the index of the first
  771.   non-zero element of a specified array.  If the optional parameter
  772.   `start_index' is given, the search will take place starting
  773.   from that index.  If a non-zero element is not found, the function
  774.   will return NULL.
  775.  
  776.  NOTES
  777.   The single parameter version of this function is equivalent to
  778.  
  779.      define wherefirst (a)
  780.      {
  781.         variable i = where (a);
  782.         if (length(i))
  783.           return i[0];
  784.         else
  785.           return NULL;
  786.      }
  787.  
  788.  
  789.  SEE ALSO
  790.   where, wherelast
  791.  
  792. --------------------------------------------------------------
  793.  
  794. wherelast
  795.  
  796.  SYNOPSIS
  797.   Get the index of the last non-zero array element
  798.  
  799.  USAGE
  800.   Int_Type wherelast (Array_Type a [,start_index])
  801.  
  802.  DESCRIPTION
  803.   The `wherelast' function returns the index of the last
  804.   non-zero element of a specified array.  If the optional parameter
  805.   `start_index' is given, the backward search will take place starting
  806.   from that index.  If a non-zero element is not found, the function
  807.   will return NULL.
  808.  
  809.  NOTES
  810.   The single parameter version of this function is equivalent to
  811.  
  812.      define wherefirst (a)
  813.      {
  814.         variable i = where (a);
  815.         if (length(i))
  816.           return i[-1];
  817.         else
  818.           return NULL;
  819.      }
  820.  
  821.  
  822.  SEE ALSO
  823.   where, wherefirst
  824.  
  825. --------------------------------------------------------------
  826.  
  827. assoc_delete_key
  828.  
  829.  SYNOPSIS
  830.   Delete a key from an Associative Array
  831.  
  832.  USAGE
  833.   assoc_delete_key (Assoc_Type a, String_Type k)
  834.  
  835.  DESCRIPTION
  836.   The `assoc_delete_key' function deletes a key given by `k'
  837.   from the associative array `a'.  If the specified key does not
  838.   exist in `a', then this function has no effect.
  839.  
  840.  SEE ALSO
  841.   assoc_key_exists, assoc_get_keys
  842.  
  843. --------------------------------------------------------------
  844.  
  845. assoc_get_keys
  846.  
  847.  SYNOPSIS
  848.   Return all the key names of an Associative Array
  849.  
  850.  USAGE
  851.   String_Type[] assoc_get_keys (Assoc_Type a)
  852.  
  853.  DESCRIPTION
  854.   This function returns all the key names of an associative array
  855.   `a' as an ordinary one dimensional array of strings.  If the
  856.   associative array contains no keys, an empty array will be returned.
  857.  
  858.  SEE ALSO
  859.   assoc_get_values, assoc_key_exists, assoc_delete_key, length
  860.  
  861. --------------------------------------------------------------
  862.  
  863. assoc_get_values
  864.  
  865.  SYNOPSIS
  866.   Return all the values of an Associative Array
  867.  
  868.  USAGE
  869.   Array_Type assoc_get_keys (Assoc_Type a)
  870.  
  871.  DESCRIPTION
  872.   This function returns all the values in the associative array
  873.   `a' as an array of proper type.  If the associative array
  874.   contains no keys, an empty array will be returned.
  875.  
  876.  EXAMPLE
  877.   Suppose that `a' is an associative array of type
  878.   Integer_Type, i.e., it was created via
  879.  
  880.       variable a = Assoc_Type[Integer_Type];
  881.  
  882.   The the following may be used to print the values of the array in
  883.   ascending order:
  884.  
  885.       static define int_sort_fun (x, y)
  886.       {
  887.          return sign (x - y);
  888.       }
  889.       define sort_and_print_values (a)
  890.       {
  891.          variable v = assoc_get_values (a);
  892.          variable i = array_sort (v, &int_sort_fun);
  893.          v = v[i];
  894.          foreach (v)
  895.            {
  896.               variable vi = ();
  897.               () = fprintf (stdout, "%d\n", vi);
  898.            }
  899.       }
  900.  
  901.  
  902.  SEE ALSO
  903.   assoc_get_values, assoc_key_exists, assoc_delete_key, array_sort
  904.  
  905. --------------------------------------------------------------
  906.  
  907. assoc_key_exists
  908.  
  909.  SYNOPSIS
  910.   Check to see whether a key exists in an Associative Array
  911.  
  912.  USAGE
  913.   Integer_Type assoc_key_exists (Assoc_Type a, String_Type k)
  914.  
  915.  DESCRIPTION
  916.   The `assoc_key_exists' function may be used to determine whether
  917.   or not a specified key `k' exists in an associative array `a'.
  918.   It returns 1 if the key exists, or 0 if it does not.
  919.  
  920.  SEE ALSO
  921.   assoc_get_keys, assoc_get_values, assoc_delete_key
  922.  
  923. --------------------------------------------------------------
  924.  
  925. array_to_bstring
  926.  
  927.  SYNOPSIS
  928.   Convert an array to a binary string
  929.  
  930.  USAGE
  931.   BString_Type array_to_bstring (Array_Type a)
  932.  
  933.  DESCRIPTION
  934.    The `array_to_bstring' function returns the elements of an
  935.    array `a' as a binary string.
  936.  
  937.  SEE ALSO
  938.   bstring_to_array, init_char_array
  939.  
  940. --------------------------------------------------------------
  941.  
  942. bstring_to_array
  943.  
  944.  SYNOPSIS
  945.   Convert a binary string to an array of characters
  946.  
  947.  USAGE
  948.   UChar_Type[] bstring_to_array (BString_Type b)
  949.  
  950.  DESCRIPTION
  951.    The `bstring_to_array' function returns an array of unsigned
  952.    characters whose elements correspond to the bytes in the
  953.    binary string.
  954.  
  955.  SEE ALSO
  956.   array_to_bstring, init_char_array
  957.  
  958. --------------------------------------------------------------
  959.  
  960. bstrlen
  961.  
  962.  SYNOPSIS
  963.   Get the length of a binary string
  964.  
  965.  USAGE
  966.   UInt_Type bstrlen (BString_Type s)
  967.  
  968.  DESCRIPTION
  969.   The `bstrlen' function may be used to obtain the length of a
  970.   binary string.  A binary string differs from an ordinary string (a C
  971.   string) in that a binary string may include null chracters.
  972.  
  973.  EXAMPLE
  974.  
  975.     s = "hello\0";
  976.     len = bstrlen (s);      % ==> len = 6
  977.     len = strlen (s);       % ==> len = 5
  978.  
  979.  
  980.  SEE ALSO
  981.   strlen, length
  982.  
  983. --------------------------------------------------------------
  984.  
  985. count_byte_occurances
  986.  
  987.  SYNOPSIS
  988.   Count the number of occurances of a byte in a binary string
  989.  
  990.  USAGE
  991.   UInt_Type count_byte_occurances (bstring, byte)
  992.  
  993.  DESCRIPTION
  994.   This function returns the number of times the specified byte
  995.   occurs in the binary string `bstr'.
  996.  
  997.  NOTES
  998.   This function uses byte-semanics.  If character semantics are
  999.   desired, use the `count_char_occurances' function.
  1000.  
  1001.  SEE ALSO
  1002.   count_char_occurances
  1003.  
  1004. --------------------------------------------------------------
  1005.  
  1006. pack
  1007.  
  1008.  SYNOPSIS
  1009.   Pack objects into a binary string
  1010.  
  1011.  USAGE
  1012.   BString_Type pack (String_Type fmt, ...)
  1013.  
  1014.  DESCRIPTION
  1015.   The `pack' function combines zero or more objects (represented
  1016.   by the ellipses above) into a binary string according to the format
  1017.   string `fmt'.
  1018.  
  1019.   The format string consists of one or more data-type specification
  1020.   characters defined by the following table:
  1021.  
  1022.      c     signed byte
  1023.      C     unsigned byte
  1024.      h     short
  1025.      H     unsigned short
  1026.      i     int
  1027.      I     unsigned int
  1028.      l     long
  1029.      L     unsigned long
  1030.      m     long long
  1031.      M     unsigned long long
  1032.      j     16 bit int
  1033.      J     16 bit unsigned int
  1034.      k     32 bit int
  1035.      K     32 bit unsigned int
  1036.      q     64 bit int
  1037.      Q     64 bit unsigned int
  1038.      f     float
  1039.      d     double
  1040.      F     32 bit float
  1041.      D     64 bit float
  1042.      s     character string, null padded
  1043.      S     character string, space padded
  1044.      z     character string, null padded
  1045.      x     a null pad character
  1046.  
  1047.   A decimal length specifier may follow the data-type specifier.  With
  1048.   the exception of the `s' and `S' specifiers, the length
  1049.   specifier indicates how many objects of that data type are to be
  1050.   packed or unpacked from the string.  When used with the `s',
  1051.   `S', or `z' specifiers, it indicates the field width to be
  1052.   used.  If the length specifier is not present, the length defaults
  1053.   to one.
  1054.  
  1055.   When packing, unlike the `s' specifier, the `z' specifier
  1056.   guarantees that at least one null byte will be written even if the
  1057.   field has to be truncated to do so.
  1058.  
  1059.   With the exception of `c', `C', `s', `S', and
  1060.   `x', each of these may be prefixed by a character that indicates
  1061.   the byte-order of the object:
  1062.  
  1063.      >    big-endian order (network order)
  1064.      <    little-endian order
  1065.      =    native byte-order
  1066.  
  1067.   The default is to use native byte order.
  1068.  
  1069.   When unpacking via the `unpack' function, if the length
  1070.   specifier is greater than one, then an array of that length will be
  1071.   returned.  In addition, trailing whitespace and null characters are
  1072.   stripped when unpacking an object given by the `S' specifier.
  1073.   Trailing null characters will be stripped from an object represented
  1074.   by the `z' specifier.  No such stripping is performed by the `s'
  1075.   specifier.
  1076.  
  1077.  EXAMPLE
  1078.  
  1079.      a = pack ("cc", 'A', 'B');         % ==> a = "AB";
  1080.      a = pack ("c2", 'A', 'B');         % ==> a = "AB";
  1081.      a = pack ("xxcxxc", 'A', 'B');     % ==> a = "\0\0A\0\0B";
  1082.      a = pack ("h2", 'A', 'B');         % ==> a = "\0A\0B" or "\0B\0A"
  1083.      a = pack (">h2", 'A', 'B');        % ==> a = "\0\xA\0\xB"
  1084.      a = pack ("<h2", 'A', 'B');        % ==> a = "\0B\0A"
  1085.      a = pack ("s4", "AB", "CD");       % ==> a = "AB\0\0"
  1086.      a = pack ("s4s2", "AB", "CD");     % ==> a = "AB\0\0CD"
  1087.      a = pack ("S4", "AB", "CD");       % ==> a = "AB  "
  1088.      a = pack ("S4S2", "AB", "CD");     % ==> a = "AB  CD"
  1089.      a = pack ("z4", "AB");             % ==> a = "AB\0\0"
  1090.      a = pack ("s4", "ABCDEFG");        % ==> a = "ABCD"
  1091.      a = pack ("z4", "ABCDEFG");        % ==> a = "ABC\0"
  1092.  
  1093.  
  1094.  SEE ALSO
  1095.   unpack, sizeof_pack, pad_pack_format, sprintf
  1096.  
  1097. --------------------------------------------------------------
  1098.  
  1099. pad_pack_format
  1100.  
  1101.  SYNOPSIS
  1102.   Add padding to a pack format
  1103.  
  1104.  USAGE
  1105.   BString_Type pad_pack_format (String_Type fmt)
  1106.  
  1107.  DESCRIPTION
  1108.   The `pad_pack_format' function may be used to add the
  1109.   appropriate padding characters to the format `fmt' such that the
  1110.   data types specified by the format will be properly aligned on word
  1111.   boundaries.  This is especially important when reading or writing files
  1112.   that assume the native alignment.
  1113.  
  1114.  SEE ALSO
  1115.   pack, unpack, sizeof_pack
  1116.  
  1117. --------------------------------------------------------------
  1118.  
  1119. sizeof_pack
  1120.  
  1121.  SYNOPSIS
  1122.   Compute the size implied by a pack format string
  1123.  
  1124.  USAGE
  1125.   UInt_Type sizeof_pack (String_Type fmt)
  1126.  
  1127.  DESCRIPTION
  1128.   The `sizeof_pack' function returns the size of the binary string
  1129.   represented by the format string `fmt'.  This information may be
  1130.   needed when reading a structure from a file.
  1131.  
  1132.  SEE ALSO
  1133.   pack, unpack, pad_pack_format
  1134.  
  1135. --------------------------------------------------------------
  1136.  
  1137. unpack
  1138.  
  1139.  SYNOPSIS
  1140.   Unpack Objects from a Binary String
  1141.  
  1142.  USAGE
  1143.   (...) = unpack (String_Type fmt, BString_Type s)
  1144.  
  1145.  DESCRIPTION
  1146.   The `unpack' function unpacks objects from a binary string
  1147.   `s' according to the format `fmt' and returns the objects to
  1148.   the stack in the order in which they were unpacked.  See the
  1149.   documentation of the `pack' function for details about the
  1150.   format string.
  1151.  
  1152.  EXAMPLE
  1153.  
  1154.     (x,y) = unpack ("cc", "AB");          % ==> x = 'A', y = 'B'
  1155.     x = unpack ("c2", "AB");              % ==> x = ['A', 'B']
  1156.     x = unpack ("x<H", "\0\xAB\xCD");     % ==> x = 0xCDABuh
  1157.     x = unpack ("xxs4", "a b c\0d e f");  % ==> x = "b c\0"
  1158.     x = unpack ("xxS4", "a b c\0d e f");  % ==> x = "b c"
  1159.  
  1160.  
  1161.  SEE ALSO
  1162.   pack, sizeof_pack, pad_pack_format
  1163.  
  1164. --------------------------------------------------------------
  1165.  
  1166. Assoc_Type
  1167.  
  1168.  SYNOPSIS
  1169.   An associative array or hash type
  1170.  
  1171.  DESCRIPTION
  1172.   An Assoc_Type object is like an array except that it is
  1173.   indexed using strings and not integers.  Unlike an Array_Type
  1174.   object, the size of an associative array is not fixed, but grows as
  1175.   objects are added to the array.  Another difference is that ordinary
  1176.   arrays represent ordered object; however, the ordering of the
  1177.   elements of an `Assoc_Type' object is unspecified.
  1178.  
  1179.   An Assoc_Type object whose elements are of some data-type
  1180.   `d' may be created using using
  1181.  
  1182.     A = Assoc_Type[d];
  1183.  
  1184.   For example,
  1185.  
  1186.     A = Assoc_Type[Int_Type];
  1187.  
  1188.   will create an associative array of integers.  To create an
  1189.   associative array capable of storing an arbitrary type, use the form
  1190.  
  1191.     A = Assoc_Type[];
  1192.  
  1193.  
  1194.   An optional parameter may be used to specify a default value for
  1195.   array elements.  For example,
  1196.  
  1197.    A = Assoc_Type[Int_Type, -1];
  1198.  
  1199.   creates an integer-valued associative array with a default element
  1200.   value of -1.  Then `A["foo"]' will return -1 if the key
  1201.   `"foo"' does not exist in the array.  Default values are
  1202.   available only if the type was specified when the associative array
  1203.   was created.
  1204.  
  1205.   The following functions may be used with associative arrays:
  1206.  
  1207.     assoc_get_keys
  1208.     assoc_get_values
  1209.     assoc_key_exists
  1210.     assoc_delete_key
  1211.  
  1212.   The `length' function may be used to obtain the number of
  1213.   elements in the array.
  1214.  
  1215.   The `foreach' construct may be used with associative arrays via
  1216.   one of the following forms:
  1217.  
  1218.       foreach k,v (A) {...}
  1219.       foreach k (A) using ("keys") { ... }
  1220.       foreach v (A) using ("values") { ... }
  1221.       foreach k,v (A) using ("keys", "values") { ... }
  1222.  
  1223.   In all the above forms, the loop is over all elements of the array
  1224.   such that `v=A[k]'.
  1225.  
  1226.  SEE ALSO
  1227.   List_Type, Array_Type, Struct_Type
  1228.  
  1229. --------------------------------------------------------------
  1230.  
  1231. List_Type
  1232.  
  1233.  SYNOPSIS
  1234.   A list object
  1235.  
  1236.  DESCRIPTION
  1237.   An object of type `List_Type' represents a list, which is
  1238.   defined as an ordered heterogeneous collection of objects.
  1239.   A list may be created using, e.g.,
  1240.  
  1241.     empty_list = {};
  1242.     list_with_4_items = {[1:10], "three", 9, {1,2,3}};
  1243.  
  1244.   Note that the last item of the list in the last example is also a
  1245.   list.  A List_Type object may be manipulated by the following
  1246.   functions:
  1247.  
  1248.     list_new
  1249.     list_insert
  1250.     list_append
  1251.     list_delete
  1252.     list_reverse
  1253.     list_pop
  1254.  
  1255.   A `List_Type' object may be indexed using an array syntax with
  1256.   the first item on the list given by an index of 0.  The
  1257.   `length' function may be used to obtain the number of elements
  1258.   in the list.
  1259.  
  1260.   A copy of the list may be created using the @ operator, e.g.,
  1261.   `copy = @list'.
  1262.  
  1263.   The `foreach' statement may be used with a List_Type
  1264.   object to loop over its elements:
  1265.  
  1266.     foreach elem (list) {....}
  1267.  
  1268.  
  1269.  SEE ALSO
  1270.   Array_Type, Assoc_Type, Struct_Type
  1271.  
  1272. --------------------------------------------------------------
  1273.  
  1274. String_Type
  1275.  
  1276.  SYNOPSIS
  1277.   A string object
  1278.  
  1279.  DESCRIPTION
  1280.   An object of type `String_Type' represents a string of bytes or
  1281.   characters, which in general have different semantics depending upon
  1282.   the UTF-8 mode.
  1283.  
  1284.   The string obeys byte-semantics when indexed as an
  1285.   array.  That is, `S[0]' will return the first byte of the
  1286.   string `S'.  For character semantics, the nth character in the
  1287.   string may be obtained using `substr' function.
  1288.  
  1289.   The `foreach' statement may be used with a String_Type
  1290.   object `S' to loop over its bytes:
  1291.  
  1292.     foreach b (S) {....}
  1293.     foreach b (S) using ("bytes") {....}
  1294.  
  1295.   To loop over its characters, the following form may be used:
  1296.  
  1297.     foreach c (S) using ("chars") {...}
  1298.  
  1299.   When UTF-8 mode is not in effect, the byte and character forms will
  1300.   produce the same sequence.  Otherwise, the string will be decoded
  1301.   to generate the (wide) character sequence.  If the string contains
  1302.   an invalid UTF-8 encoded character, sucessive bytes of the invalid
  1303.   sequence will be returned as negative integers.  For example,
  1304.   `"a\xAB\x{AB}"' specifies a string composed of the character
  1305.   `a', a byte `0xAB', and the character `0xAB'.  In
  1306.   this case,
  1307.  
  1308.      foreach c ("a\xAB\x{AB}") {...}
  1309.  
  1310.   will produce the integer-valued sequence `'a', -0xAB, 0xAB'.
  1311.  
  1312.  SEE ALSO
  1313.   Array_Type, _slang_utf8_ok
  1314.  
  1315. --------------------------------------------------------------
  1316.  
  1317. Struct_Type
  1318.  
  1319.  SYNOPSIS
  1320.   A structure datatype
  1321.  
  1322.  DESCRIPTION
  1323.   A Struct_Type object with fields `f1', `f2',...,
  1324.   `fN' may be created using
  1325.  
  1326.     s = struct { f1, f2, ..., fN };
  1327.  
  1328.   The fields may be accessed via the "dot" operator, e.g.,
  1329.  
  1330.      s.f1 = 3;
  1331.      if (s12.f1 == 4) s.f1++;
  1332.  
  1333.   By default, all fields will be initialized to NULL.
  1334.  
  1335.   A structure may also be created using the dereference operator (@):
  1336.  
  1337.     s = @Struct_Type ("f1", "f2", ..., "fN");
  1338.     s = @Struct_Type ( ["f1", "f2", ..., "fN"] );
  1339.  
  1340.   Functions for manipulating structure fields include:
  1341.  
  1342.      _push_struct_field_values
  1343.      get_struct_field
  1344.      get_struct_field_names
  1345.      set_struct_field
  1346.      set_struct_fields
  1347.  
  1348.  
  1349.   The `foreach' loop may be used to loop over elements of a linked
  1350.   list.  Suppose that first structure in the list is called
  1351.   `root', and that the `child' field is used to form the
  1352.   chain.  Then one may walk the list using:
  1353.  
  1354.      foreach s (root) using ("child")
  1355.       {
  1356.          % s will take on successive values in the list
  1357.           .
  1358.           .
  1359.       }
  1360.  
  1361.   The loop will terminate when the last elements `child' field is
  1362.   NULL.  If no ``linking'' field is specified, the field name will
  1363.   default to `next'.
  1364.  
  1365.   User-defined data types are similar to the `Struct_Type'.  A
  1366.   type, e.g., `Vector_Type' may be created using:
  1367.  
  1368.     typedef struct { x, y, z } Vector_Type;
  1369.  
  1370.   Objects of this type may be created via the @ operator, e.g.,
  1371.  
  1372.     v = @Vector_Type;
  1373.  
  1374.   It is recommended that this be used in a function for creating such
  1375.   types, e.g.,
  1376.  
  1377.     define vector (x, y, z)
  1378.     {
  1379.        variable v = @Vector_Type;
  1380.        v.x = x;
  1381.        v.y = y;
  1382.        v.z = z;
  1383.        return v;
  1384.     }
  1385.  
  1386.   The action of the binary and unary operators may be defined for such
  1387.   types.  Consider the "+" operator.  First define a function for
  1388.   adding two `Vector_Type' objects:
  1389.  
  1390.     static define vector_add (v1, v2)
  1391.     {
  1392.        return vector (v1.x+v2.x, v1.y+v2.y, v1.z, v2.z);
  1393.     }
  1394.  
  1395.   Then use
  1396.  
  1397.     __add_binary ("+", Vector_Type, &vector_add, Vector_Type, Vector_Type);
  1398.  
  1399.   to indicate that the function is to be called whenever the "+"
  1400.   binary operation between two `Vector_Type' objects takes place,
  1401.   e.g.,
  1402.  
  1403.     V1 = vector (1, 2, 3);
  1404.     V2 = vector (8, 9, 1);
  1405.     V3 = V1 + V2;
  1406.  
  1407.   will assigned the vector (9, 11, 4) to `V3'.  Similarly, the
  1408.   `"*"' operator between scalars and vectors may be defined using:
  1409.  
  1410.     static define vector_scalar_mul (v, a)
  1411.     {
  1412.        return vector (a*v.x, a*v.y, a*v.z);
  1413.     }
  1414.     static define scalar_vector_mul (a, v)
  1415.     {
  1416.        return vector_scalar_mul (v, a);
  1417.     }
  1418.     __add_binary ("*", Vector_Type, &scalar_vector_mul, Any_Type, Vector_Type);
  1419.     __add_binary ("*", Vector_Type, &vector_scalar_mul, Vector_Type, Any_Type);
  1420.  
  1421.   Related functions include:
  1422.  
  1423.     __add_unary
  1424.     __add_string
  1425.     __add_destroy
  1426.  
  1427.  
  1428.  SEE ALSO
  1429.   List_Type, Assoc_Type
  1430.  
  1431. --------------------------------------------------------------
  1432.  
  1433. File_Type
  1434.  
  1435.  SYNOPSIS
  1436.   A type representing a C stdio object
  1437.  
  1438.  DESCRIPTION
  1439.   An File_Type is the interpreter's representation of a C
  1440.   stdio FILE object and is usually created using the `fopen'
  1441.   function, i.e.,
  1442.  
  1443.     fp = fopen ("file.dat", "r");
  1444.  
  1445.   Functions that utilize the File_Type include:
  1446.  
  1447.     fopen
  1448.     fclose
  1449.     fgets
  1450.     fputs
  1451.     ferror
  1452.     feof
  1453.     fflush
  1454.     fprintf
  1455.     fseek
  1456.     ftell
  1457.     fread
  1458.     fwrite
  1459.     fread_bytes
  1460.  
  1461.   The `foreach' construct may be used with File_Type
  1462.   objects via one of the following forms:
  1463.  
  1464.    foreach line (fp) {...}
  1465.    foreach byte (A) using ("char") { ... }   % read bytes
  1466.    foreach line (A) using ("line") { ... }   % read lines (default)
  1467.    foreach line (A) using ("wsline") { ... } % whitespace stripped from lines
  1468.  
  1469.  
  1470.  SEE ALSO
  1471.   List_Type, Array_Type, Struct_Type
  1472.  
  1473. --------------------------------------------------------------
  1474.  
  1475. _bofeof_info
  1476.  
  1477.  SYNOPSIS
  1478.   Control the generation of function callback code
  1479.  
  1480.  USAGE
  1481.   Int_Type _bofeof_info
  1482.  
  1483.  DESCRIPTION
  1484.  This value of this variable dictates whether or not the S-Lang
  1485.  interpeter will generate code to call the beginning and end of
  1486.  function callback handlers.  The value of this variable is local to
  1487.  the compilation unit, but is inherited by other units loaded by the
  1488.  current unit.
  1489.  
  1490.  If the value of this variable is 1 when a function is defined, then
  1491.  when the function is executed, the callback handlers defined via
  1492.  `_set_bof_handler' and `_set_eof_handler' will be called.
  1493.  
  1494.  SEE ALSO
  1495.   _set_bof_handler, _set_eof_handler, _boseos_info
  1496.  
  1497. --------------------------------------------------------------
  1498.  
  1499. _boseos_info
  1500.  
  1501.  SYNOPSIS
  1502.   Control the generation of BOS/EOS callback code
  1503.  
  1504.  USAGE
  1505.   Int_Type _boseos_info
  1506.  
  1507.  DESCRIPTION
  1508.  This value of this variable dictates whether or not the S-Lang
  1509.  interpeter will generate code to call the beginning and end of
  1510.  statement callback handlers.  The value of this variable is local to
  1511.  the compilation unit, but is inherited by other units loaded by the
  1512.  current unit.
  1513.  
  1514.  The value of `_boseos_info' controls the generation of code for
  1515.  callbacks as follows:
  1516.  
  1517.    Value      Description
  1518.    -----------------------------------------------------------------
  1519.      0        No code for making callbacks will be produced.
  1520.      1        Callback generation will take place for all non-branching
  1521.               and looping statements.
  1522.      2        Same as for 1 with the addition that code will also be
  1523.               generated for branching statements (if, !if, loop, ...)
  1524.      3        Same as 2, but also including break and continue
  1525.               statements.
  1526.  
  1527.  A non-branching statement is one that does not effect chain of
  1528.  execution.  Branching statements include all looping statements,
  1529.  conditional statement, `break', `continue', and `return'.
  1530.  
  1531.  EXAMPLE
  1532.  Consider the following:
  1533.  
  1534.    _boseos_info = 1;
  1535.    define foo ()
  1536.    {
  1537.       if (some_expression)
  1538.         some_statement;
  1539.    }
  1540.    _boseos_info = 2;
  1541.    define bar ()
  1542.    {
  1543.       if (some_expression)
  1544.         some_statement;
  1545.    }
  1546.  
  1547.  The function `foo' will be compiled with code generated to call the
  1548.  BOS and EOS handlers when `some_statement' is executed.  The
  1549.  function `bar' will be compiled with code to call the handlers
  1550.  for both `some_expression' and `some_statement'.
  1551.  
  1552.  NOTES
  1553.  The `sldb' debugger and `slsh''s `stkcheck.sl' make use of this
  1554.  facility.
  1555.  
  1556.  SEE ALSO
  1557.   _set_bos_handler, _set_eos_handler, _bofeof_info
  1558.  
  1559. --------------------------------------------------------------
  1560.  
  1561. _clear_error
  1562.  
  1563.  SYNOPSIS
  1564.   Clear an error condition (deprecated)
  1565.  
  1566.  USAGE
  1567.   _clear_error ()
  1568.  
  1569.  DESCRIPTION
  1570.   This function has been deprecated.  New code should make use of
  1571.   try-catch exception handling.
  1572.  
  1573.   This function may be used in error-blocks to clear the error that
  1574.   triggered execution of the error block.  Execution resumes following
  1575.   the statement, in the scope of the error-block, that triggered the
  1576.   error.
  1577.  
  1578.  EXAMPLE
  1579.   Consider the following wrapper around the `putenv' function:
  1580.  
  1581.     define try_putenv (name, value)
  1582.     {
  1583.        variable status;
  1584.        ERROR_BLOCK
  1585.         {
  1586.           _clear_error ();
  1587.           status = -1;
  1588.         }
  1589.        status = 0;
  1590.        putenv (sprintf ("%s=%s", name, value);
  1591.        return status;
  1592.     }
  1593.  
  1594.   If `putenv' fails, it generates an error condition, which the
  1595.   `try_putenv' function catches and clears.  Thus `try_putenv'
  1596.   is a function that returns -1 upon failure and 0 upon
  1597.   success.
  1598.  
  1599.  SEE ALSO
  1600.   _trace_function, _slangtrace, _traceback
  1601.  
  1602. --------------------------------------------------------------
  1603.  
  1604. _set_bof_handler
  1605.  
  1606.  SYNOPSIS
  1607.   Set the beginning of function callback handler
  1608.  
  1609.  USAGE
  1610.   _set_bof_handler (Ref_Type func)
  1611.  
  1612.  DESCRIPTION
  1613.  This function is used to set the function to be called prior to the
  1614.  execution of the body S-Lang function but after its arguments have
  1615.  been evaluated, provided that function was defined
  1616.  with `_bofeof_info' set appropriately.  The callback function
  1617.  must be defined to take a single parameter representing the name of
  1618.  the function and must return nothing.
  1619.  
  1620.  EXAMPLE
  1621.  
  1622.     private define bof_handler (fun)
  1623.     {
  1624.       () = fputs ("About to execute $fun"$, stdout);
  1625.     }
  1626.     _set_bos_handler (&bof_handler);
  1627.  
  1628.  
  1629.  NOTES
  1630.  
  1631.  SEE ALSO
  1632.   _set_eof_handler, _boseos_info, _set_bos_handler
  1633.  
  1634. --------------------------------------------------------------
  1635.  
  1636. _set_bos_handler
  1637.  
  1638.  SYNOPSIS
  1639.   Set the beginning of statement callback handler
  1640.  
  1641.  USAGE
  1642.   _set_bos_handler (Ref_Type func)
  1643.  
  1644.  DESCRIPTION
  1645.  This function is used to set the function to be called prior to the
  1646.  beginning of a statement.  The function will be passed two
  1647.  parameters: the name of the file and the line number of the statement
  1648.  to be executed.  It should return nothing.
  1649.  
  1650.  EXAMPLE
  1651.  
  1652.     private define bos_handler (file, line)
  1653.     {
  1654.       () = fputs ("About to execute $file:$line\n"$, stdout);
  1655.     }
  1656.     _set_bos_handler (&bos_handler);
  1657.  
  1658.  
  1659.  NOTES
  1660.  The beginning and end of statement handlers will be called for
  1661.  statements in a file only if that file was compiled with the variable
  1662.  `_boseos_info' set to a non-zero value.
  1663.  
  1664.  SEE ALSO
  1665.   _set_eos_handler, _boseos_info, _bofeof_info
  1666.  
  1667. --------------------------------------------------------------
  1668.  
  1669. _set_eof_handler
  1670.  
  1671.  SYNOPSIS
  1672.   Set the beginning of function callback handler
  1673.  
  1674.  USAGE
  1675.   _set_eof_handler (Ref_Type func)
  1676.  
  1677.  DESCRIPTION
  1678.  This function is used to set the function to be called at the end of
  1679.  execution of a S-Lang function, provided that function was compiled with
  1680.  `_bofeof_info' set accordingly.
  1681.  
  1682.  The callback function will be passed no parameters and it must return
  1683.  nothing.
  1684.  
  1685.  EXAMPLE
  1686.  
  1687.    private define eof_handler ()
  1688.    {
  1689.      () = fputs ("Done executing the function\n", stdout);
  1690.    }
  1691.    _set_eof_handler (&eof_handler);
  1692.  
  1693.  
  1694.  SEE ALSO
  1695.   _set_bof_handler, _bofeof_info, _boseos_info
  1696.  
  1697. --------------------------------------------------------------
  1698.  
  1699. _set_eos_handler
  1700.  
  1701.  SYNOPSIS
  1702.   Set the end of statement callback handler
  1703.  
  1704.  USAGE
  1705.   _set_eos_handler (Ref_Type func)
  1706.  
  1707.  DESCRIPTION
  1708.  This function is used to set the function to be called at the end of
  1709.  a statement.  The function will be passed no parameters and it should
  1710.  return nothing.
  1711.  
  1712.  EXAMPLE
  1713.  
  1714.    private define eos_handler ()
  1715.    {
  1716.      () = fputs ("Done executing the statement\n", stdout);
  1717.    }
  1718.    _set_eos_handler (&eos_handler);
  1719.  
  1720.  
  1721.  NOTES
  1722.  The beginning and end of statement handlers will be called for
  1723.  statements in a file only if that file was compiled with the variable
  1724.  `_boseos_info' set to a non-zero value.
  1725.  
  1726.  SEE ALSO
  1727.   _set_bos_handler, _boseos_info, _bofeof_info
  1728.  
  1729. --------------------------------------------------------------
  1730.  
  1731. _slangtrace
  1732.  
  1733.  SYNOPSIS
  1734.   Turn function tracing on or off
  1735.  
  1736.  USAGE
  1737.   Integer_Type _slangtrace
  1738.  
  1739.  DESCRIPTION
  1740.   The `_slangtrace' variable is a debugging aid that when set to a
  1741.   non-zero value enables tracing when function declared by
  1742.   `_trace_function' is entered.  If the value is greater than
  1743.   zero, both intrinsic and user defined functions will get traced.
  1744.   However, if set to a value less than zero, intrinsic functions will
  1745.   not get traced.
  1746.  
  1747.  SEE ALSO
  1748.   _trace_function, _traceback, _print_stack
  1749.  
  1750. --------------------------------------------------------------
  1751.  
  1752. _traceback
  1753.  
  1754.  SYNOPSIS
  1755.   Generate a traceback upon error
  1756.  
  1757.  USAGE
  1758.   Integer_Type _traceback
  1759.  
  1760.  DESCRIPTION
  1761.   `_traceback' is an intrinsic integer variable whose bitmapped value
  1762.   controls the generation of the call-stack traceback upon error.
  1763.   When set to 0, no traceback will be generated.  Otherwise its value
  1764.   is the bitwise-or of the following integers:
  1765.  
  1766.        1        Create a full traceback
  1767.        2        Omit local variable information
  1768.        4        Generate just one line of traceback
  1769.  
  1770.   The default value of this variable is 4.
  1771.  
  1772.  NOTES
  1773.   Running `slsh' with the `-g' option causes this variable to be
  1774.   set to 1.
  1775.  
  1776.  SEE ALSO
  1777.   _boseos_info
  1778.  
  1779. --------------------------------------------------------------
  1780.  
  1781. _trace_function
  1782.  
  1783.  SYNOPSIS
  1784.   Set the function to trace
  1785.  
  1786.  USAGE
  1787.   _trace_function (String_Type f)
  1788.  
  1789.  DESCRIPTION
  1790.   `_trace_function' declares that the S-Lang function with name
  1791.   `f' is to be traced when it is called.  Calling
  1792.   `_trace_function' does not in itself turn tracing on.  Tracing
  1793.   is turned on only when the variable `_slangtrace' is non-zero.
  1794.  
  1795.  SEE ALSO
  1796.   _slangtrace, _traceback
  1797.  
  1798. --------------------------------------------------------------
  1799.  
  1800. _get_frame_info
  1801.  
  1802.  SYNOPSIS
  1803.   Get information about a stack frame
  1804.  
  1805.  USAGE
  1806.   Struct_Type _get_frame_info (Integer_Type depth)
  1807.  
  1808.  DESCRIPTION
  1809.   `_get_frame_info' returns a structure with information about
  1810.   the function call stack from of depth `depth'. The structure
  1811.   contains the following fields:
  1812.  
  1813.     file: The file that contains the code of the stack frame.
  1814.     line: The line number the file the stack frame is in.
  1815.     function: the name of the function containing the code of the stack
  1816.       frame; it might be NULL if the code isn't inside a function.
  1817.     locals: Array of String_Type containing the names of variables local
  1818.       to the stack frame; it might be NULL if the stack frame doesn't
  1819.       belong to a function.
  1820.     namespace: The namespace the code of this stack frame is in.
  1821.  
  1822.  
  1823.  SEE ALSO
  1824.   _get_frame_variable, _use_frame_namespace
  1825.  
  1826. --------------------------------------------------------------
  1827.  
  1828. _get_frame_variable
  1829.  
  1830.  SYNOPSIS
  1831.   Get the value of a variable local to a stack frame
  1832.  
  1833.  USAGE
  1834.   Any_Type _get_frame_variable (Integer_Type depth, String_Type name)
  1835.  
  1836.  DESCRIPTION
  1837.   This function returns value of the variable `name' in the stack
  1838.   frame at depth `depth'.  This might not only be a local variable but
  1839.   also variables from outer scopes, e.g., a variable private to the
  1840.   namespace.
  1841.  
  1842.   If no variable with this name is found an `UndefinedNameError'
  1843.   will be thrown.  An `VariableUninitializedError' will be
  1844.   generated if the variable has no value.
  1845.  
  1846.  SEE ALSO
  1847.   _get_frame_info, _use_frame_namespace
  1848.  
  1849. --------------------------------------------------------------
  1850.  
  1851. _use_frame_namespace
  1852.  
  1853.  SYNOPSIS
  1854.   Selects the namespace of a stack frame
  1855.  
  1856.  USAGE
  1857.   _use_frame_namespace (Integer_Type depth)
  1858.  
  1859.  DESCRIPTION
  1860.   This function sets the current namespace to the one belonging to the
  1861.   call stack frame at depth `depth'.
  1862.  
  1863.  SEE ALSO
  1864.   _get_frame_info, _get_frame_variable
  1865.  
  1866. --------------------------------------------------------------
  1867.  
  1868. access
  1869.  
  1870.  SYNOPSIS
  1871.   Check to see if a file is accessable
  1872.  
  1873.  USAGE
  1874.   Int_Type access (String_Type pathname, Int_Type mode)
  1875.  
  1876.  DESCRIPTION
  1877.  This functions checks to see if the current process has access to the
  1878.  specified pathname.  The `mode' parameter determines the type of
  1879.  desired access.  Its value is given by the bitwise-or of one or more
  1880.  of the following constants:
  1881.  
  1882.     R_OK   Check for read permission
  1883.     W_OK   Check for write permission
  1884.     X_OK   Check for execute permission
  1885.     F_OK   Check for existence
  1886.  
  1887.  
  1888.  The function will return 0 if process has the requested access
  1889.  permissions to the file, otherwise it will return -1 and set
  1890.  `errno' accordingly.
  1891.  
  1892.  Access to a file depend not only upon the file itself, but also upon
  1893.  the permissions of each of the directories in the pathname.  The
  1894.  checks are done using the real user and group ids of the process, and
  1895.  not using the effective ids.
  1896.  
  1897.  SEE ALSO
  1898.   stat_file
  1899.  
  1900. --------------------------------------------------------------
  1901.  
  1902. chdir
  1903.  
  1904.  SYNOPSIS
  1905.   Change the current working directory
  1906.  
  1907.  USAGE
  1908.   Int_Type chdir (String_Type dir)
  1909.  
  1910.  DESCRIPTION
  1911.   The `chdir' function may be used to change the current working
  1912.   directory to the directory specified by `dir'.  Upon success it
  1913.   returns zero.  Upon failure it returns `-1' and sets
  1914.   `errno' accordingly.
  1915.  
  1916.  SEE ALSO
  1917.   mkdir, stat_file
  1918.  
  1919. --------------------------------------------------------------
  1920.  
  1921. chmod
  1922.  
  1923.  SYNOPSIS
  1924.   Change the mode of a file
  1925.  
  1926.  USAGE
  1927.   Int_Type chmod (String_Type file, Int_Type mode)
  1928.  
  1929.  DESCRIPTION
  1930.   The `chmod' function changes the permissions of the specified
  1931.   file to those given by `mode'.  It returns `0' upon
  1932.   success, or `-1' upon failure setting `errno' accordingly.
  1933.  
  1934.   See the system specific documentation for the C library
  1935.   function `chmod' for a discussion of the `mode' parameter.
  1936.  
  1937.  SEE ALSO
  1938.   chown, stat_file
  1939.  
  1940. --------------------------------------------------------------
  1941.  
  1942. chown
  1943.  
  1944.  SYNOPSIS
  1945.   Change the owner of a file
  1946.  
  1947.  USAGE
  1948.   Int_Type chown (String_Type file, Int_Type uid, Int_Type gid)
  1949.  
  1950.  DESCRIPTION
  1951.   The `chown' function is used to change the user-id and group-id of
  1952.   `file' to `uid' and `gid', respectively.  It returns
  1953.   0 upon success and -1 upon failure, with `errno'
  1954.   set accordingly.
  1955.  
  1956.  NOTES
  1957.   On most systems, only the superuser can change the ownership of a
  1958.   file.
  1959.  
  1960.   Some systems do not support this function.
  1961.  
  1962.  SEE ALSO
  1963.   chmod, stat_file
  1964.  
  1965. --------------------------------------------------------------
  1966.  
  1967. getcwd
  1968.  
  1969.  SYNOPSIS
  1970.   Get the current working directory
  1971.  
  1972.  USAGE
  1973.   String_Type getcwd ()
  1974.  
  1975.  DESCRIPTION
  1976.   The `getcwd' function returns the absolute pathname of the
  1977.   current working directory.  If an error occurs or it cannot
  1978.   determine the working directory, it returns NULL and sets
  1979.   `errno' accordingly.
  1980.  
  1981.  NOTES
  1982.   Under Unix, OS/2, and MSDOS, the pathname returned by this function
  1983.   includes the trailing slash character.  It may also include
  1984.   the drive specifier for systems where that is meaningful.
  1985.  
  1986.  SEE ALSO
  1987.   mkdir, chdir, errno
  1988.  
  1989. --------------------------------------------------------------
  1990.  
  1991. hardlink
  1992.  
  1993.  SYNOPSIS
  1994.   Create a hard-link
  1995.  
  1996.  USAGE
  1997.   Int_Type hardlink (String_Type oldpath, String_Type newpath)
  1998.  
  1999.  DESCRIPTION
  2000.   The `hardlink' function creates a hard-link called
  2001.   `newpath' to the existing file `oldpath'.  If the link was
  2002.   sucessfully created, the function will return 0.  Upon error, the
  2003.   function returns -1 and sets `errno' accordingly.
  2004.  
  2005.  NOTES
  2006.   Not all systems support the concept of a hard-link.
  2007.  
  2008.  SEE ALSO
  2009.   symlink
  2010.  
  2011. --------------------------------------------------------------
  2012.  
  2013. listdir
  2014.  
  2015.  SYNOPSIS
  2016.   Get a list of the files in a directory
  2017.  
  2018.  USAGE
  2019.   String_Type[] listdir (String_Type dir)
  2020.  
  2021.  DESCRIPTION
  2022.   The `listdir' function returns the directory listing of all the
  2023.   files in the specified directory `dir' as an array of strings.
  2024.   It does not return the special files `".."' and `"."' as
  2025.   part of the list.
  2026.  
  2027.  SEE ALSO
  2028.   stat_file, stat_is, length
  2029.  
  2030. --------------------------------------------------------------
  2031.  
  2032. lstat_file
  2033.  
  2034.  SYNOPSIS
  2035.   Get information about a symbolic link
  2036.  
  2037.  USAGE
  2038.   Struct_Type lstat_file (String_Type file)
  2039.  
  2040.  DESCRIPTION
  2041.   The `lstat_file' function behaves identically to `stat_file'
  2042.   but if `file' is a symbolic link, `lstat_file' returns
  2043.   information about the link itself, and not the file that it
  2044.   references.
  2045.  
  2046.   See the documentation for `stat_file' for more information.
  2047.  
  2048.  NOTES
  2049.   On systems that do not support symbolic links, there is no
  2050.   difference between this function and the `stat_file' function.
  2051.  
  2052.  SEE ALSO
  2053.   stat_file, readlink
  2054.  
  2055. --------------------------------------------------------------
  2056.  
  2057. mkdir
  2058.  
  2059.  SYNOPSIS
  2060.   Create a new directory
  2061.  
  2062.  USAGE
  2063.   Int_Type mkdir (String_Type dir [,Int_Type mode])
  2064.  
  2065.  DESCRIPTION
  2066.   The `mkdir' function creates a directory whose name is specified
  2067.   by the `dir' parameter with permissions given by the optional
  2068.   `mode' parameter.  Upon success `mkdir' returns 0, or it
  2069.   returns `-1' upon failure setting `errno' accordingly.  In
  2070.   particular, if the directory already exists, the function will fail
  2071.   and set errno to EEXIST.
  2072.  
  2073.  EXAMPLE
  2074.  
  2075.      define my_mkdir (dir)
  2076.      {
  2077.         if (0 == mkdir (dir)) return;
  2078.         if (errno == EEXIST) return;
  2079.         throw IOError,
  2080.            sprintf ("mkdir %s failed: %s", dir, errno_string (errno));
  2081.      }
  2082.  
  2083.  
  2084.  NOTES
  2085.   The `mode' parameter may not be meaningful on all systems.  On
  2086.   systems where it is meaningful, the actual permissions on the newly
  2087.   created directory are modified by the process's umask.
  2088.  
  2089.  SEE ALSO
  2090.   rmdir, getcwd, chdir, fopen, errno
  2091.  
  2092. --------------------------------------------------------------
  2093.  
  2094. readlink
  2095.  
  2096.  SYNOPSIS
  2097.   String_Type readlink (String_Type path)
  2098.  
  2099.  USAGE
  2100.   Get the value of a symbolic link
  2101.  
  2102.  DESCRIPTION
  2103.   The `readlink' function returns the value of a symbolic link.
  2104.   Upon failure, NULL is returned and `errno' set accordingly.
  2105.  
  2106.  NOTES
  2107.   Not all systems support this function.
  2108.  
  2109.  SEE ALSO
  2110.   symlink, lstat_file, stat_file, stat_is
  2111.  
  2112. --------------------------------------------------------------
  2113.  
  2114. remove
  2115.  
  2116.  SYNOPSIS
  2117.   Delete a file
  2118.  
  2119.  USAGE
  2120.   Int_Type remove (String_Type file)
  2121.  
  2122.  DESCRIPTION
  2123.   The `remove' function deletes a file.  It returns 0 upon
  2124.   success, or -1 upon error and sets `errno' accordingly.
  2125.  
  2126.  SEE ALSO
  2127.   rename, rmdir
  2128.  
  2129. --------------------------------------------------------------
  2130.  
  2131. rename
  2132.  
  2133.  SYNOPSIS
  2134.   Rename a file
  2135.  
  2136.  USAGE
  2137.   Int_Type rename (String_Type old, String_Type new)
  2138.  
  2139.  DESCRIPTION
  2140.   The `rename' function renames a file from `old' to `new'
  2141.   moving it between directories if necessary.  This function may fail
  2142.   if the directories are not on the same file system.  It returns
  2143.   0 upon success, or -1 upon error and sets `errno' accordingly.
  2144.  
  2145.  SEE ALSO
  2146.   remove, errno
  2147.  
  2148. --------------------------------------------------------------
  2149.  
  2150. rmdir
  2151.  
  2152.  SYNOPSIS
  2153.   Remove a directory
  2154.  
  2155.  USAGE
  2156.   Int_Type rmdir (String_Type dir)
  2157.  
  2158.  DESCRIPTION
  2159.   The `rmdir' function deletes the specified directory.  It returns
  2160.   0 upon success or -1 upon error and sets `errno' accordingly.
  2161.  
  2162.  NOTES
  2163.   The directory must be empty before it can be removed.
  2164.  
  2165.  SEE ALSO
  2166.   rename, remove, mkdir
  2167.  
  2168. --------------------------------------------------------------
  2169.  
  2170. stat_file
  2171.  
  2172.  SYNOPSIS
  2173.   Get information about a file
  2174.  
  2175.  USAGE
  2176.   Struct_Type stat_file (String_Type file)
  2177.  
  2178.  DESCRIPTION
  2179.   The `stat_file' function returns information about `file'
  2180.   through the use of the system `stat' call.  If the stat call
  2181.   fails, the function returns NULL and sets errno accordingly.
  2182.   If it is successful, it returns a stat structure with the following
  2183.   integer-value fields:
  2184.  
  2185.     st_dev
  2186.     st_ino
  2187.     st_mode
  2188.     st_nlink
  2189.     st_uid
  2190.     st_gid
  2191.     st_rdev
  2192.     st_size
  2193.     st_atime
  2194.     st_mtime
  2195.     st_ctime
  2196.  
  2197.   See the C library documentation of `stat' for a discussion of the
  2198.   meanings of these fields.
  2199.  
  2200.  EXAMPLE
  2201.   The following example shows how the `stat_file' function may be
  2202.   used to get the size of a file:
  2203.  
  2204.      define file_size (file)
  2205.      {
  2206.         variable st;
  2207.         st = stat_file(file);
  2208.         if (st == NULL)
  2209.           throw IOError, "Unable to stat $file"$;
  2210.         return st.st_size;
  2211.      }
  2212.  
  2213.  
  2214.  SEE ALSO
  2215.   lstat_file, stat_is
  2216.  
  2217. --------------------------------------------------------------
  2218.  
  2219. stat_is
  2220.  
  2221.  SYNOPSIS
  2222.   Parse the st_mode field of a stat structure
  2223.  
  2224.  USAGE
  2225.   Char_Type stat_is (String_Type type, Int_Type st_mode)
  2226.  
  2227.  DESCRIPTION
  2228.   The `stat_is' function returns a boolean value according to
  2229.   whether or not the `st_mode' parameter is of the specified type.
  2230.   Specifically, `type' must be one of the strings:
  2231.  
  2232.      "sock"     (socket)
  2233.      "fifo"     (fifo)
  2234.      "blk"      (block device)
  2235.      "chr"      (character device)
  2236.      "reg"      (regular file)
  2237.      "lnk"      (link)
  2238.      "dir"      (dir)
  2239.  
  2240.   It returns a non-zero value if `st_mode' corresponds to
  2241.   `type'.
  2242.  
  2243.  EXAMPLE
  2244.   The following example illustrates how to use the `stat_is'
  2245.   function to determine whether or not a file is a directory:
  2246.  
  2247.      define is_directory (file)
  2248.      {
  2249.         variable st;
  2250.  
  2251.         st = stat_file (file);
  2252.         if (st == NULL) return 0;
  2253.         return stat_is ("dir", st.st_mode);
  2254.      }
  2255.  
  2256.  
  2257.  SEE ALSO
  2258.   stat_file, lstat_file
  2259.  
  2260. --------------------------------------------------------------
  2261.  
  2262. symlink
  2263.  
  2264.  SYNOPSIS
  2265.   Create a symbolic link
  2266.  
  2267.  USAGE
  2268.   status = symlink (String_Type oldpath, String_Type new_path)
  2269.  
  2270.  DESCRIPTION
  2271.   The `symlink' function may be used to create a symbolic link
  2272.   named `new_path' for  `oldpath'.  If successful, the function
  2273.   returns 0, otherwise it returns -1 and sets `errno' appropriately.
  2274.  
  2275.  NOTES
  2276.   This function is not supported on all systems and even if supported,
  2277.   not all file systems support the concept of a symbolic link.
  2278.  
  2279.  SEE ALSO
  2280.   readlink, hardlink
  2281.  
  2282. --------------------------------------------------------------
  2283.  
  2284. _$
  2285.  
  2286.  SYNOPSIS
  2287.   Expand the dollar-escaped variables in a string
  2288.  
  2289.  USAGE
  2290.   String_Type _$(String_Type s)
  2291.  
  2292.  DESCRIPTION
  2293.  This function expands the dollar-escaped variables in a string and
  2294.  returns the resulting string.
  2295.  
  2296.  EXAMPLE
  2297.  Consider the following code fragment:
  2298.  
  2299.      private variable Format = "/tmp/foo-$time.$pid";
  2300.      define make_filename ()
  2301.      {
  2302.         variable pid = getpid ();
  2303.         variable time = _time ();
  2304.         return _$(Format);
  2305.      }
  2306.  
  2307.  Note that the variable `Format' contains dollar-escaped
  2308.  variables, but because the `$' suffix was omitted from the
  2309.  string literal, the variables are not expanded.  Instead expansion is
  2310.  deferred until execution of the `make_filename' function through
  2311.  the use of the `_$' function.
  2312.  
  2313.  SEE ALSO
  2314.   eval, getenv
  2315.  
  2316. --------------------------------------------------------------
  2317.  
  2318. autoload
  2319.  
  2320.  SYNOPSIS
  2321.   Load a function from a file
  2322.  
  2323.  USAGE
  2324.   autoload (String_Type funct, String_Type file)
  2325.  
  2326.  DESCRIPTION
  2327.   The `autoload' function is used to declare `funct' to the
  2328.   interpreter and indicate that it should be loaded from `file'
  2329.   when it is actually used.  If `func' contains a namespace
  2330.   prefix, then the file will be loaded into the corresponding
  2331.   namespace.  Otherwise, if the `autoload' function is called
  2332.   from an execution namespace that is not the Global namespace nor an
  2333.   anonymous namespace, then the file will be loaded into the execution
  2334.   namespace.
  2335.  
  2336.  EXAMPLE
  2337.     Suppose `bessel_j0' is a function defined in the file
  2338.     `bessel.sl'.  Then the statement
  2339.  
  2340.       autoload ("bessel_j0", "bessel.sl");
  2341.  
  2342.     will cause `bessel.sl' to be loaded prior to the execution of
  2343.     `bessel_j0'.
  2344.  
  2345.  SEE ALSO
  2346.   evalfile, import
  2347.  
  2348. --------------------------------------------------------------
  2349.  
  2350. byte_compile_file
  2351.  
  2352.  SYNOPSIS
  2353.   Compile a file to byte-code for faster loading.
  2354.  
  2355.  USAGE
  2356.   byte_compile_file (String_Type file, Int_Type method)
  2357.  
  2358.  DESCRIPTION
  2359.   The `byte_compile_file' function byte-compiles `file'
  2360.   producing a new file with the same name except a `'c'' is added
  2361.   to the output file name.  For example, `file' is
  2362.   `"site.sl"', then this function produces a new file named
  2363.   `site.slc'.
  2364.  
  2365.  NOTES
  2366.   The `method' parameter is not used in the current
  2367.   implementation, but may be in the future.  For now, set
  2368.   it to `0'.
  2369.  
  2370.  SEE ALSO
  2371.   evalfile
  2372.  
  2373. --------------------------------------------------------------
  2374.  
  2375. eval
  2376.  
  2377.  SYNOPSIS
  2378.   Interpret a string as S-Lang code
  2379.  
  2380.  USAGE
  2381.   eval (String_Type expression [,String_Type namespace])
  2382.  
  2383.  DESCRIPTION
  2384.   The `eval' function parses a string as S-Lang code and executes the
  2385.   result.  If called with the optional namespace argument, then the
  2386.   string will be evaluated in the specified namespace.  If that
  2387.   namespace does not exist it will be created first.
  2388.  
  2389.   This is a useful function in many contexts including those where
  2390.   it is necessary to dynamically generate function definitions.
  2391.  
  2392.  EXAMPLE
  2393.  
  2394.     if (0 == is_defined ("my_function"))
  2395.       eval ("define my_function () { message (\"my_function\"); }");
  2396.  
  2397.  
  2398.  SEE ALSO
  2399.   is_defined, autoload, evalfile
  2400.  
  2401. --------------------------------------------------------------
  2402.  
  2403. evalfile
  2404.  
  2405.  SYNOPSIS
  2406.   Interpret a file containing S-Lang code
  2407.  
  2408.  USAGE
  2409.   Int_Type evalfile (String_Type file [,String_Type namespace])
  2410.  
  2411.  DESCRIPTION
  2412.   The `evalfile' function loads `file' into the interpreter
  2413.   and executes it.  If called with the optional namespace argument,
  2414.   the file will be loaded into the specified namespace, which will be
  2415.   created if necessary.  If given no namespace argument and the file
  2416.   has already been loaded, then it will be loaded again into an
  2417.   anonymous namespace.  A namespace argument given by the empty string
  2418.   will also cause the file to be loaded into a new anonymous namespace.
  2419.  
  2420.   If no errors were encountered, 1 will be returned; otherwise,
  2421.   a S-Lang exception will be thrown and the function will return zero.
  2422.  
  2423.  EXAMPLE
  2424.  
  2425.     define load_file (file)
  2426.     {
  2427.        try
  2428.        {
  2429.          () = evalfile (file);
  2430.        }
  2431.        catch AnyError;
  2432.     }
  2433.  
  2434.  
  2435.  NOTES
  2436.   For historical reasons, the return value of this function is not
  2437.   really useful.
  2438.  
  2439.   The file is searched along an application-defined load-path.  The
  2440.   `get_slang_load_path' and `set_slang_load_path' functions
  2441.   may be used to set and query the path.
  2442.  
  2443.  SEE ALSO
  2444.   eval, autoload, set_slang_load_path, get_slang_load_path
  2445.  
  2446. --------------------------------------------------------------
  2447.  
  2448. get_slang_load_path
  2449.  
  2450.  SYNOPSIS
  2451.   Get the value of the interpreter's load-path
  2452.  
  2453.  USAGE
  2454.   String_Type get_slang_load_path ()
  2455.  
  2456.  DESCRIPTION
  2457.   This function retrieves the value of the delimiter-separated search
  2458.   path used for loading files.  The delimiter is OS-specific and may
  2459.   be queried using the `path_get_delimiter' function.
  2460.  
  2461.  NOTES
  2462.   Some applications may not support the built-in load-path searching
  2463.   facility provided by the underlying library.
  2464.  
  2465.  SEE ALSO
  2466.   set_slang_load_path, path_get_delimiter
  2467.  
  2468. --------------------------------------------------------------
  2469.  
  2470. set_slang_load_path
  2471.  
  2472.  SYNOPSIS
  2473.   Set the value of the interpreter's load-path
  2474.  
  2475.  USAGE
  2476.   set_slang_load_path (String_Type path)
  2477.  
  2478.  DESCRIPTION
  2479.   This function may be used to set the value of the
  2480.   delimiter-separated search path used by the `evalfile' and
  2481.   `autoload' functions for locating files.  The delimiter is
  2482.   OS-specific and may be queried using the `path_get_delimiter'
  2483.   function.
  2484.  
  2485.  EXAMPLE
  2486.  
  2487.     public define prepend_to_slang_load_path (p)
  2488.     {
  2489.        variable s = stat_file (p);
  2490.        if (s == NULL) return;
  2491.        if (0 == stat_is ("dir", s.st_mode))
  2492.          return;
  2493.  
  2494.        p = sprintf ("%s%c%s", p, path_get_delimiter (), get_slang_load_path ());
  2495.        set_slang_load_path (p);
  2496.     }
  2497.  
  2498.  
  2499.  NOTES
  2500.   Some applications may not support the built-in load-path searching
  2501.   facility provided by the underlying library.
  2502.  
  2503.  SEE ALSO
  2504.   get_slang_load_path, path_get_delimiter, evalfile, autoload
  2505.  
  2506. --------------------------------------------------------------
  2507.  
  2508. get_import_module_path
  2509.  
  2510.  SYNOPSIS
  2511.   Get the search path for dynamically loadable objects
  2512.  
  2513.  USAGE
  2514.   String_Type get_import_module_path ()
  2515.  
  2516.  DESCRIPTION
  2517.   The `get_import_module_path' may be used to get the search path
  2518.   for dynamically shared objects.  Such objects may be made accessible
  2519.   to the application via the `import' function.
  2520.  
  2521.  SEE ALSO
  2522.   import, set_import_module_path
  2523.  
  2524. --------------------------------------------------------------
  2525.  
  2526. import
  2527.  
  2528.  SYNOPSIS
  2529.   Dynamically link to a specified module
  2530.  
  2531.  USAGE
  2532.   import (String_Type module [, String_Type namespace])
  2533.  
  2534.  DESCRIPTION
  2535.   The `import' function causes the run-time linker to dynamically
  2536.   link to the shared object specified by the `module' parameter.
  2537.   It searches for the shared object as follows: First a search is
  2538.   performed along all module paths specified by the application.  Then
  2539.   a search is made along the paths defined via the
  2540.   `set_import_module_path' function.  If not found, a search is
  2541.   performed along the paths given by the `SLANG_MODULE_PATH'
  2542.   environment variable.  Finally, a system dependent search is
  2543.   performed (e.g., using the `LD_LIBRARY_PATH' environment
  2544.   variable).
  2545.  
  2546.   The optional second parameter may be used to specify a namespace
  2547.   for the intrinsic functions and variables of the module.  If this
  2548.   parameter is not present, the intrinsic objects will be placed into
  2549.   the active namespace, or global namespace if the active namespace is
  2550.   anonymous.
  2551.  
  2552.   This function throws an `ImportError' if the specified module is
  2553.   not found.
  2554.  
  2555.  NOTES
  2556.   The `import' function is not available on all systems.
  2557.  
  2558.  SEE ALSO
  2559.   set_import_module_path, use_namespace, current_namespace, getenv, evalfile
  2560.  
  2561. --------------------------------------------------------------
  2562.  
  2563. set_import_module_path
  2564.  
  2565.  SYNOPSIS
  2566.   Set the search path for dynamically loadable objects
  2567.  
  2568.  USAGE
  2569.   set_import_module_path (String_Type path_list)
  2570.  
  2571.  DESCRIPTION
  2572.   The `set_import_module_path' may be used to set the search path
  2573.   for dynamically shared objects.  Such objects may be made accessible
  2574.   to the application via the `import' function.
  2575.  
  2576.   The actual syntax for the specification of the set of paths will
  2577.   vary according to the operating system.  Under Unix, a colon
  2578.   character is used to separate paths in `path_list'.  For win32
  2579.   systems a semi-colon is used.  The `path_get_delimiter'
  2580.   function may be used to get the value of the delimiter.
  2581.  
  2582.  SEE ALSO
  2583.   import, get_import_module_path, path_get_delimiter
  2584.  
  2585. --------------------------------------------------------------
  2586.  
  2587. add_doc_file
  2588.  
  2589.  SYNOPSIS
  2590.   Make a documentation file known to the help system
  2591.  
  2592.  USAGE
  2593.   add_doc_file (String_Type file)
  2594.  
  2595.  DESCRIPTION
  2596.   The `add_doc_file' is used to add a documentation file to the
  2597.   system.  Such files are searched by the
  2598.   `get_doc_string_from_file' function.  The `file' must be
  2599.   specified using the full path.
  2600.  
  2601.  SEE ALSO
  2602.   set_doc_files, get_doc_files, get_doc_string_from_file
  2603.  
  2604. --------------------------------------------------------------
  2605.  
  2606. _apropos
  2607.  
  2608.  SYNOPSIS
  2609.   Generate a list of functions and variables
  2610.  
  2611.  USAGE
  2612.   Array_Type _apropos (String_Type ns, String_Type s, Integer_Type flags)
  2613.  
  2614.  DESCRIPTION
  2615.   The `_apropos' function may be used to get a list of all defined
  2616.   objects in the namespace `ns' whose name matches the regular
  2617.   expression `s' and whose type matches those specified by
  2618.   `flags'.  It returns an array of strings containing the names
  2619.   matched.
  2620.  
  2621.   The second parameter `flags' is a bit mapped value whose bits
  2622.   are defined according to the following table
  2623.  
  2624.      1          Intrinsic Function
  2625.      2          User-defined Function
  2626.      4          Intrinsic Variable
  2627.      8          User-defined Variable
  2628.  
  2629.  
  2630.  EXAMPLE
  2631.  
  2632.     define apropos (s)
  2633.     {
  2634.       variable n, name, a;
  2635.       a = _apropos ("Global", s, 0xF);
  2636.  
  2637.       vmessage ("Found %d matches:", length (a));
  2638.       foreach name (a)
  2639.         message (name);
  2640.     }
  2641.  
  2642.   prints a list of all matches.
  2643.  
  2644.  NOTES
  2645.   If the namespace specifier `ns' is the empty string `""',
  2646.   then the namespace will default to the static namespace of the
  2647.   current compilation unit.
  2648.  
  2649.  SEE ALSO
  2650.   is_defined, sprintf, _get_namespaces
  2651.  
  2652. --------------------------------------------------------------
  2653.  
  2654. _function_name
  2655.  
  2656.  SYNOPSIS
  2657.   Returns the name of the currently executing function
  2658.  
  2659.  USAGE
  2660.   String_Type _function_name ()
  2661.  
  2662.  DESCRIPTION
  2663.   This function returns the name of the currently executing function.
  2664.   If called from top-level, it returns the empty string.
  2665.  
  2666.  SEE ALSO
  2667.   _trace_function, is_defined
  2668.  
  2669. --------------------------------------------------------------
  2670.  
  2671. __get_defined_symbols
  2672.  
  2673.  SYNOPSIS
  2674.   Get the symbols defined by the preprocessor
  2675.  
  2676.  USAGE
  2677.   Int_Type __get_defined_symbols ()
  2678.  
  2679.  DESCRIPTION
  2680.   The `__get_defined_symbols' functions is used to get the list of
  2681.   all the symbols defined by the S-Lang preprocessor.  It pushes each
  2682.   of the symbols on the stack followed by the number of items pushed.
  2683.  
  2684.  SEE ALSO
  2685.   is_defined, _apropos, _get_namespaces
  2686.  
  2687. --------------------------------------------------------------
  2688.  
  2689. get_doc_files
  2690.  
  2691.  SYNOPSIS
  2692.   Get the list of documentation files
  2693.  
  2694.  USAGE
  2695.   String_Type[] = get_doc_files ()
  2696.  
  2697.  DESCRIPTION
  2698.   The `get_doc_files' function returns the internal list of
  2699.   documentation files as an array of strings.
  2700.  
  2701.  SEE ALSO
  2702.   set_doc_files, add_doc_file, get_doc_string_from_file
  2703.  
  2704. --------------------------------------------------------------
  2705.  
  2706. get_doc_string_from_file
  2707.  
  2708.  SYNOPSIS
  2709.   Read documentation from a file
  2710.  
  2711.  USAGE
  2712.   String_Type get_doc_string_from_file ([String_Type f,] String_Type t)
  2713.  
  2714.  DESCRIPTION
  2715.   If called with two arguments, `get_doc_string_from_file' opens
  2716.   the documentation file `f' and searches it for topic `t'.
  2717.   Otherwise, it will search an internal list of documentation files
  2718.   looking for the documentation associated with the topic `t'.  If
  2719.   found, the documentation for `t' will be returned, otherwise the
  2720.   function will return NULL.
  2721.  
  2722.   Files may be added to the internal list via the `add_doc_file'
  2723.   or `set_doc_files' functions.
  2724.  
  2725.  SEE ALSO
  2726.   add_doc_file, set_doc_files, get_doc_files, _slang_doc_dir
  2727.  
  2728. --------------------------------------------------------------
  2729.  
  2730. _get_namespaces
  2731.  
  2732.  SYNOPSIS
  2733.   Returns a list of namespace names
  2734.  
  2735.  USAGE
  2736.   String_Type[] _get_namespaces ()
  2737.  
  2738.  DESCRIPTION
  2739.   This function returns a string array containing the names of the
  2740.   currently defined namespaces.
  2741.  
  2742.  SEE ALSO
  2743.   _apropos, use_namespace, implements, __get_defined_symbols
  2744.  
  2745. --------------------------------------------------------------
  2746.  
  2747. is_defined
  2748.  
  2749.  SYNOPSIS
  2750.   Determine if a variable or function is defined
  2751.  
  2752.  USAGE
  2753.   Integer_Type is_defined (String_Type name)
  2754.  
  2755.  DESCRIPTION
  2756.    This function is used to determine whether or not a function or
  2757.    variable of the given name has been defined.  If the specified name
  2758.    has not been defined, the function returns 0.  Otherwise, it
  2759.    returns a non-zero value that depends on the type of object
  2760.    attached to the name. Specifically, it returns one of the following
  2761.    values:
  2762.  
  2763.      +1     intrinsic function
  2764.      +2     slang function
  2765.      -1     intrinsic variable
  2766.      -2     slang variable
  2767.       0     undefined
  2768.  
  2769.  
  2770.  EXAMPLE
  2771.     Consider the function:
  2772.  
  2773.     define runhooks (hook)
  2774.     {
  2775.        if (2 == is_defined(hook)) eval(hook);
  2776.     }
  2777.  
  2778.     This function could be called from another S-Lang function to
  2779.     allow customization of that function, e.g., if the function
  2780.     represents a mode, the hook could be called to setup keybindings
  2781.     for the mode.
  2782.  
  2783.  SEE ALSO
  2784.   typeof, eval, autoload, __get_reference, __is_initialized
  2785.  
  2786. --------------------------------------------------------------
  2787.  
  2788. __is_initialized
  2789.  
  2790.  SYNOPSIS
  2791.   Determine whether or not a variable has a value
  2792.  
  2793.  USAGE
  2794.   Integer_Type __is_initialized (Ref_Type r)
  2795.  
  2796.  DESCRIPTION
  2797.    This function returns non-zero of the object referenced by `r'
  2798.    is initialized, i.e., whether it has a value.  It returns 0 if the
  2799.    referenced object has not been initialized.
  2800.  
  2801.  EXAMPLE
  2802.    The function:
  2803.  
  2804.     define zero ()
  2805.     {
  2806.        variable f;
  2807.        return __is_initialized (&f);
  2808.     }
  2809.  
  2810.   will always return zero, but
  2811.  
  2812.     define one ()
  2813.     {
  2814.        variable f = 0;
  2815.        return __is_initialized (&f);
  2816.     }
  2817.  
  2818.   will return one.
  2819.  
  2820.  SEE ALSO
  2821.   __get_reference, __uninitialize, is_defined, typeof, eval
  2822.  
  2823. --------------------------------------------------------------
  2824.  
  2825. _NARGS
  2826.  
  2827.  SYNOPSIS
  2828.   The number of parameters passed to a function
  2829.  
  2830.  USAGE
  2831.   Integer_Type _NARGS
  2832.    The value of the `_NARGS' variable represents the number of
  2833.    arguments passed to the function.  This variable is local to each
  2834.    function.
  2835.  
  2836.  EXAMPLE
  2837.    This example uses the `_NARGS' variable to print the list of
  2838.    values passed to the function:
  2839.  
  2840.      define print_values ()
  2841.      {
  2842.         variable arg;
  2843.  
  2844.         if (_NARGS == 0)
  2845.           {
  2846.              message ("Nothing to print");
  2847.              return;
  2848.           }
  2849.         foreach arg (__pop_args (_NARGS))
  2850.           vmessage ("Argument value is: %S", arg.value);
  2851.      }
  2852.  
  2853.  
  2854.  SEE ALSO
  2855.   __pop_args, __push_args, typeof
  2856.  
  2857. --------------------------------------------------------------
  2858.  
  2859. set_doc_files
  2860.  
  2861.  SYNOPSIS
  2862.   Set the internal list of documentation files
  2863.  
  2864.  USAGE
  2865.   set_doc_files (String_Type[] list)
  2866.  
  2867.  DESCRIPTION
  2868.   The `set_doc_files' function may be used to set the internal
  2869.   list of documentation files.  It takes a single parameter, which is
  2870.   required to be an array of strings.  The internal file list is set
  2871.   to the files specified by the elements of the array.
  2872.  
  2873.  EXAMPLE
  2874.   The following example shows how to add all the files in a specified
  2875.   directory to the internal list.  It makes use of the `glob'
  2876.   function that is distributed as part of `slsh'.
  2877.  
  2878.      files = glob ("/path/to/doc/files/*.sld");
  2879.      set_doc_files ([files, get_doc_files ()]);
  2880.  
  2881.  
  2882.  SEE ALSO
  2883.   get_doc_files, add_doc_file, get_doc_string_from_file
  2884.  
  2885. --------------------------------------------------------------
  2886.  
  2887. _slang_doc_dir
  2888.  
  2889.  SYNOPSIS
  2890.   Installed documentation directory
  2891.  
  2892.  USAGE
  2893.   String_Type _slang_doc_dir
  2894.  
  2895.  DESCRIPTION
  2896.    The `_slang_doc_dir' variable is a read-only variable that
  2897.    specifies the compile-time installation location of the S-Lang
  2898.    documentation.
  2899.  
  2900.  SEE ALSO
  2901.   get_doc_string_from_file
  2902.  
  2903. --------------------------------------------------------------
  2904.  
  2905. _slang_version
  2906.  
  2907.  SYNOPSIS
  2908.   The S-Lang library version number
  2909.  
  2910.  USAGE
  2911.   Integer_Type _slang_version
  2912.  
  2913.  DESCRIPTION
  2914.    `_slang_version' is a read-only variable that gives the version
  2915.    number of the S-Lang library.
  2916.  
  2917.  SEE ALSO
  2918.   _slang_version_string
  2919.  
  2920. --------------------------------------------------------------
  2921.  
  2922. _slang_version_string
  2923.  
  2924.  SYNOPSIS
  2925.   The S-Lang library version number as a string
  2926.  
  2927.  USAGE
  2928.   String_Type _slang_version_string
  2929.  
  2930.  DESCRIPTION
  2931.   `_slang_version_string' is a read-only variable that gives a
  2932.   string representation of the version number of the S-Lang library.
  2933.  
  2934.  SEE ALSO
  2935.   _slang_version
  2936.  
  2937. --------------------------------------------------------------
  2938.  
  2939. list_append
  2940.  
  2941.  SYNOPSIS
  2942.   Append an object to a list
  2943.  
  2944.  USAGE
  2945.   list_append (List_Type list, object [,Int_Type nth])
  2946.  
  2947.  DESCRIPTION
  2948.   The `list_append' function is like `list_insert' except
  2949.   this function appends the object to the the list.  The optional
  2950.   argument `nth' may be used to specify where the object is to be
  2951.   appended.  See the documentation on `list_insert' for more details.
  2952.  
  2953.  SEE ALSO
  2954.   list_insert, list_delete, list_pop, list_new, list_reverse
  2955.  
  2956. --------------------------------------------------------------
  2957.  
  2958. list_delete
  2959.  
  2960.  SYNOPSIS
  2961.   Remove an item from a list
  2962.  
  2963.  USAGE
  2964.   list_delete (List_Type list, Int_Type nth)
  2965.  
  2966.  DESCRIPTION
  2967.   This function removes the `nth' item in the specified list.
  2968.   The first item in the list corresponds to a value of `nth'
  2969.   equal to zero.  If `nth' is negative, then the indexing is with
  2970.   respect to the end of the list with the last item corresponding to
  2971.   `nth' equal to -1.
  2972.  
  2973.  SEE ALSO
  2974.   list_insert, list_append, list_pop, list_new, list_reverse
  2975.  
  2976. --------------------------------------------------------------
  2977.  
  2978. list_insert
  2979.  
  2980.  SYNOPSIS
  2981.   Insert an item into a list
  2982.  
  2983.  USAGE
  2984.   list_insert (List_Type list, object [,Int_Type nth])
  2985.  
  2986.  DESCRIPTION
  2987.   This function may be used to insert an object into the specified
  2988.   list.  With just two arguments, the object will be inserted at the
  2989.   beginning of the list.  The optional third argument, `nth', may
  2990.   be used to specify the insertion point.  The first item in the list
  2991.   corresponds to a value of `nth' equal to zero.  If `nth'
  2992.   is negative, then the indexing is with respect to the end of the
  2993.   list with the last item given by a value of `nth' equal to -1.
  2994.  
  2995.  NOTES
  2996.   It is important to note that
  2997.  
  2998.     list_insert (list, object, 0);
  2999.  
  3000.   is not the same as
  3001.  
  3002.     list = {object, list}
  3003.  
  3004.   since the latter creates a new list with two items, `object'
  3005.   and the old list.
  3006.  
  3007.  SEE ALSO
  3008.   list_append, list_pop, list_delete, list_new, list_reverse
  3009.  
  3010. --------------------------------------------------------------
  3011.  
  3012. list_new
  3013.  
  3014.  SYNOPSIS
  3015.   Create a new list
  3016.  
  3017.  USAGE
  3018.   List_Type list_new ()
  3019.  
  3020.  DESCRIPTION
  3021.   This function creates a new empty List_Type object.  Such a
  3022.   list may also be created using the syntax
  3023.  
  3024.      list = {};
  3025.  
  3026.  
  3027.  SEE ALSO
  3028.   list_delete, list_insert, list_append, list_reverse, list_pop
  3029.  
  3030. --------------------------------------------------------------
  3031.  
  3032. list_pop
  3033.  
  3034.  SYNOPSIS
  3035.   Extract an item from a list
  3036.  
  3037.  USAGE
  3038.   object = list_pop (List_Type list [, Int_Type nth])
  3039.  
  3040.  DESCRIPTION
  3041.   The `list_pop' function returns a object from a list deleting
  3042.   the item from the list in the process.  If the second argument is
  3043.   present, then it may be used to specify the position in the list
  3044.   where the item is to be obtained.  If called with a single argument,
  3045.   the first item in the list will be used.
  3046.  
  3047.  SEE ALSO
  3048.   list_delete, list_insert, list_append, list_reverse, list_new
  3049.  
  3050. --------------------------------------------------------------
  3051.  
  3052. list_reverse
  3053.  
  3054.  SYNOPSIS
  3055.   Reverse a list
  3056.  
  3057.  USAGE
  3058.   list_reverse (List_Type list)
  3059.  
  3060.  DESCRIPTION
  3061.   This function may be used to reverse the items in list.
  3062.  
  3063.  NOTES
  3064.   This function does not create a new list.  The list passed to the
  3065.   function will be reversed upon return from the function.  If it is
  3066.   desired to create a separate reversed list, then a separate copy
  3067.   should be made, e.g.,
  3068.  
  3069.      rev_list = @list;
  3070.      list_reverse (rev_list);
  3071.  
  3072.  
  3073.  SEE ALSO
  3074.   list_new, list_insert, list_append, list_delete, list_pop
  3075.  
  3076. --------------------------------------------------------------
  3077.  
  3078. list_to_array
  3079.  
  3080.  SYNOPSIS
  3081.   Convert a list into an array
  3082.  
  3083.  USAGE
  3084.   Array_Type list_to_array (List_Type list [,DataType_Type type])
  3085.  
  3086.  DESCRIPTION
  3087.  The `list_to_array' function converts a list of objects into an
  3088.  array of the same length and returns the result.  The optional
  3089.  argument may be used to specify the array's data type.  If no
  3090.  `type' is given, `list_to_array' tries to find the common
  3091.  data type of all list elements. This function will generate an
  3092.  exception if the list is empty and no type has been specified, or the
  3093.  objects in the list cannot be converted to a common type.
  3094.  
  3095.  NOTES
  3096.  A future version of this function may produce an Any_Type
  3097.  array for an empty or heterogeneous list.
  3098.  
  3099.  SEE ALSO
  3100.   length, typecast, __pop_list, typeof, array_sort
  3101.  
  3102. --------------------------------------------------------------
  3103.  
  3104. abs
  3105.  
  3106.  SYNOPSIS
  3107.   Compute the absolute value of a number
  3108.  
  3109.  USAGE
  3110.   y = abs(x)
  3111.  
  3112.  DESCRIPTION
  3113.   The `abs' function returns the absolute value of an arithmetic
  3114.   type.  If its argument is a complex number (Complex_Type),
  3115.   then it returns the modulus.  If the argument is an array, a new
  3116.   array will be created whose elements are obtained from the original
  3117.   array by using the `abs' function.
  3118.  
  3119.  SEE ALSO
  3120.   sign, sqr
  3121.  
  3122. --------------------------------------------------------------
  3123.  
  3124. acos
  3125.  
  3126.  SYNOPSIS
  3127.   Compute the arc-cosine of a number
  3128.  
  3129.  USAGE
  3130.   y = acos (x)
  3131.  
  3132.  DESCRIPTION
  3133.   The `acos' function computes the arc-cosine of a number and
  3134.   returns the result.  If its argument is an array, the
  3135.   `acos' function will be applied to each element and the result returned
  3136.   as an array.
  3137.  
  3138.  SEE ALSO
  3139.   cos, atan, acosh, cosh
  3140.  
  3141. --------------------------------------------------------------
  3142.  
  3143. acosh
  3144.  
  3145.  SYNOPSIS
  3146.   Compute the inverse cosh of a number
  3147.  
  3148.  USAGE
  3149.   y = acosh (x)
  3150.  
  3151.  DESCRIPTION
  3152.   The `acosh' function computes the inverse hyperbolic cosine of a number and
  3153.   returns the result.  If its argument is an array, the
  3154.   `acosh' function will be applied to each element and the result returned
  3155.   as an array.
  3156.  
  3157.  SEE ALSO
  3158.   cos, atan, acosh, cosh
  3159.  
  3160. --------------------------------------------------------------
  3161.  
  3162. asin
  3163.  
  3164.  SYNOPSIS
  3165.   Compute the arc-sine of a number
  3166.  
  3167.  USAGE
  3168.   y = asin (x)
  3169.  
  3170.  DESCRIPTION
  3171.   The `asin' function computes the arc-sine of a number and
  3172.   returns the result.  If its argument is an array, the
  3173.   `asin' function will be applied to each element and the result returned
  3174.   as an array.
  3175.  
  3176.  SEE ALSO
  3177.   cos, atan, acosh, cosh
  3178.  
  3179. --------------------------------------------------------------
  3180.  
  3181. asinh
  3182.  
  3183.  SYNOPSIS
  3184.   Compute the inverse-sinh of a number
  3185.  
  3186.  USAGE
  3187.   y = asinh (x)
  3188.  
  3189.  DESCRIPTION
  3190.   The `asinh' function computes the inverse hyperbolic sine of a number and
  3191.   returns the result.  If its argument is an array, the
  3192.   `asinh' function will be applied to each element and the result returned
  3193.   as an array.
  3194.  
  3195.  SEE ALSO
  3196.   cos, atan, acosh, cosh
  3197.  
  3198. --------------------------------------------------------------
  3199.  
  3200. atan
  3201.  
  3202.  SYNOPSIS
  3203.   Compute the arc-tangent of a number
  3204.  
  3205.  USAGE
  3206.   y = atan (x)
  3207.  
  3208.  DESCRIPTION
  3209.   The `atan' function computes the arc-tangent of a number and
  3210.   returns the result.  If its argument is an array, the
  3211.   `atan' function will be applied to each element and the result returned
  3212.   as an array.
  3213.  
  3214.  SEE ALSO
  3215.   atan2, cos, acosh, cosh
  3216.  
  3217. --------------------------------------------------------------
  3218.  
  3219. atan2
  3220.  
  3221.  SYNOPSIS
  3222.   Compute the arc-tangent of the ratio of two variables
  3223.  
  3224.  USAGE
  3225.   z = atan2 (y, x)
  3226.  
  3227.  DESCRIPTION
  3228.   The `atan2' function computes the arc-tangent of the ratio
  3229.   `y/x' and returns the result as a value that has the
  3230.   proper sign for the quadrant where the point (x,y) is located.  The
  3231.   returned value `z' will satisfy (-PI < z <= PI).  If either of the
  3232.   arguments is an array, an array of the corresponding values will be returned.
  3233.  
  3234.  SEE ALSO
  3235.   hypot, cos, atan, acosh, cosh
  3236.  
  3237. --------------------------------------------------------------
  3238.  
  3239. atanh
  3240.  
  3241.  SYNOPSIS
  3242.   Compute the inverse-tanh of a number
  3243.  
  3244.  USAGE
  3245.   y = atanh (x)
  3246.  
  3247.  DESCRIPTION
  3248.   The `atanh' function computes the inverse hyperbolic tangent of a number and
  3249.   returns the result.  If its argument is an array, the
  3250.   `atanh' function will be applied to each element and the result returned
  3251.   as an array.
  3252.  
  3253.  SEE ALSO
  3254.   cos, atan, acosh, cosh
  3255.  
  3256. --------------------------------------------------------------
  3257.  
  3258. ceil
  3259.  
  3260.  SYNOPSIS
  3261.   Round x up to the nearest integral value
  3262.  
  3263.  USAGE
  3264.   y = ceil (x)
  3265.  
  3266.  DESCRIPTION
  3267.   This function rounds its numeric argument up to the nearest integral
  3268.   value. If the argument is an array, the corresponding array will be
  3269.   returned.
  3270.  
  3271.  SEE ALSO
  3272.   floor, round
  3273.  
  3274. --------------------------------------------------------------
  3275.  
  3276. Conj
  3277.  
  3278.  SYNOPSIS
  3279.   Compute the complex conjugate of a number
  3280.  
  3281.  USAGE
  3282.   z1 = Conj (z)
  3283.  
  3284.  DESCRIPTION
  3285.   The `Conj' function returns the complex conjugate of a number.
  3286.   If its argument is an array, the `Conj' function will be applied to each
  3287.   element and the result returned as an array.
  3288.  
  3289.  SEE ALSO
  3290.   Real, Imag, abs
  3291.  
  3292. --------------------------------------------------------------
  3293.  
  3294. cos
  3295.  
  3296.  SYNOPSIS
  3297.   Compute the cosine of a number
  3298.  
  3299.  USAGE
  3300.   y = cos (x)
  3301.  
  3302.  DESCRIPTION
  3303.   The `cos' function computes the cosine of a number and
  3304.   returns the result.  If its argument is an array, the
  3305.   `cos' function will be applied to each element and the result returned
  3306.   as an array.
  3307.  
  3308.  SEE ALSO
  3309.   cos, atan, acosh, cosh
  3310.  
  3311. --------------------------------------------------------------
  3312.  
  3313. cosh
  3314.  
  3315.  SYNOPSIS
  3316.   Compute the hyperbolic cosine of a number
  3317.  
  3318.  USAGE
  3319.   y = cosh (x)
  3320.  
  3321.  DESCRIPTION
  3322.   The `cosh' function computes the hyperbolic cosine of a number and
  3323.   returns the result.  If its argument is an array, the
  3324.   `cosh' function will be applied to each element and the result returned
  3325.   as an array.
  3326.  
  3327.  SEE ALSO
  3328.   cos, atan, acosh, cosh
  3329.  
  3330. --------------------------------------------------------------
  3331.  
  3332. _diff
  3333.  
  3334.  SYNOPSIS
  3335.   Compute the absolute difference of two values
  3336.  
  3337.  USAGE
  3338.   y = _diff (x, y)
  3339.  
  3340.  DESCRIPTION
  3341.   The `_diff' function returns a floating point number equal to
  3342.   the absolute value of the difference of its two arguments.
  3343.   If either argument is an array, an array of the corresponding values
  3344.   will be returned.
  3345.  
  3346.  SEE ALSO
  3347.   abs
  3348.  
  3349. --------------------------------------------------------------
  3350.  
  3351. exp
  3352.  
  3353.  SYNOPSIS
  3354.   Compute the exponential of a number
  3355.  
  3356.  USAGE
  3357.   y = exp (x)
  3358.  
  3359.  DESCRIPTION
  3360.   The `exp' function computes the exponential of a number and
  3361.   returns the result.  If its argument is an array, the
  3362.   `exp' function will be applied to each element and the result returned
  3363.   as an array.
  3364.  
  3365.  SEE ALSO
  3366.   expm1, cos, atan, acosh, cosh
  3367.  
  3368. --------------------------------------------------------------
  3369.  
  3370. expm1
  3371.  
  3372.  SYNOPSIS
  3373.   Compute exp(x)-1
  3374.  
  3375.  USAGE
  3376.   y = expm1(x)
  3377.  
  3378.  DESCRIPTION
  3379.   The `expm1' function computes `exp(x)-1' and returns the
  3380.   result.  If its argument is an array, the `expm1' function will
  3381.   be applied to each element and the results returned as an array.
  3382.  
  3383.   This function should be called whenever `x' is close to 0 to
  3384.   avoid the numerical error that would arise in a naive computation of
  3385.   `exp(x)-1'.
  3386.  
  3387.  SEE ALSO
  3388.   expm1, log1p, cos, atan, acosh, cosh
  3389.  
  3390. --------------------------------------------------------------
  3391.  
  3392. feqs
  3393.  
  3394.  SYNOPSIS
  3395.   Test the approximate equality of two numbers
  3396.  
  3397.  USAGE
  3398.   Char_Type feqs (a, b [,reldiff [,absdiff]]
  3399.  
  3400.  DESCRIPTION
  3401.  This function compares two floating point numbers `a' and
  3402.  `b', and returns a non-zero value if they are equal to within a
  3403.  specified tolerance; otherwise 0 will be returned.  If either is an
  3404.  array, a corresponding boolean array will be returned.
  3405.  
  3406.  The tolerances are specified as relative and absolute differences via
  3407.  the optional third and fourth arguments.  If no optional arguments
  3408.  are present, the tolerances default to `reldiff=0.01' and
  3409.  `absdiff=1e-6'.  If only the relative difference has been
  3410.  specified, the absolute difference (`absdiff') will be taken to
  3411.  be 0.0.
  3412.  
  3413.  For the case when `|b|>=|a|', `a' and `b' are
  3414.  considered to be equal to within the specified tolerances if either
  3415.  `|b-a|<=absdiff' or `|b-a|/|b|<=reldiff' is true.
  3416.  
  3417.  SEE ALSO
  3418.   fneqs, fgteqs, flteqs
  3419.  
  3420. --------------------------------------------------------------
  3421.  
  3422. fgteqs
  3423.  
  3424.  SYNOPSIS
  3425.   Compare two numbers using specified tolerances
  3426. .
  3427.  
  3428.  USAGE
  3429.   Char_Type feqs (a, b [,reldiff [,absdiff]]
  3430.  
  3431.  DESCRIPTION
  3432.   This function is functionally equivalent to:
  3433.  
  3434.      (a >= b) or feqs(a,b,...)
  3435.  
  3436.   See the documentation of `feqs' for more information.
  3437.  
  3438.  SEE ALSO
  3439.   feqs, fneqs, flteqs
  3440.  
  3441. --------------------------------------------------------------
  3442.  
  3443. floor
  3444.  
  3445.  SYNOPSIS
  3446.   Round x down to the nearest integer
  3447.  
  3448.  USAGE
  3449.   y = floor (x)
  3450.  
  3451.  DESCRIPTION
  3452.   This function rounds its numeric argument down to the nearest
  3453.   integral value. If the argument is an array, the corresponding array
  3454.   will be returned.
  3455.  
  3456.  SEE ALSO
  3457.   ceil, round, nint
  3458.  
  3459. --------------------------------------------------------------
  3460.  
  3461. flteqs
  3462.  
  3463.  SYNOPSIS
  3464.   Compare two numbers using specified tolerances
  3465. .
  3466.  
  3467.  USAGE
  3468.   Char_Type feqs (a, b [,reldiff [,absdiff]]
  3469.  
  3470.  DESCRIPTION
  3471.   This function is functionally equivalent to:
  3472.  
  3473.      (a <= b) or feqs(a,b,...)
  3474.  
  3475.   See the documentation of `feqs' for more information.
  3476.  
  3477.  SEE ALSO
  3478.   feqs, fneqs, fgteqs
  3479.  
  3480. --------------------------------------------------------------
  3481.  
  3482. fneqs
  3483.  
  3484.  SYNOPSIS
  3485.   Test the approximate inequality of two numbers
  3486.  
  3487.  USAGE
  3488.   Char_Type feqs (a, b [,reldiff [,absdiff]]
  3489.  
  3490.  DESCRIPTION
  3491.   This function is functionally equivalent to:
  3492.  
  3493.     not fneqs(a,b,...)
  3494.  
  3495.   See the documentation of `feqs' for more information.
  3496.  
  3497.  SEE ALSO
  3498.   feqs, fgteqs, flteqs
  3499.  
  3500. --------------------------------------------------------------
  3501.  
  3502. get_float_format
  3503.  
  3504.  SYNOPSIS
  3505.   Get the format for printing floating point values.
  3506.  
  3507.  USAGE
  3508.   String_Type get_float_format ()
  3509.  
  3510.  DESCRIPTION
  3511.  The `get_float_format' retrieves the format string used for
  3512.  printing single and double precision floating point numbers.  See the
  3513.  documentation for the `set_float_format' function for more
  3514.  information about the format.
  3515.  
  3516.  SEE ALSO
  3517.   set_float_format
  3518.  
  3519. --------------------------------------------------------------
  3520.  
  3521. hypot
  3522.  
  3523.  SYNOPSIS
  3524.   Compute sqrt(x^2+y^2)
  3525.  
  3526.  USAGE
  3527.   r = hypot (x [,y])
  3528.  
  3529.  DESCRIPTION
  3530.   If given two arguments, `hypot' function computes the quantity
  3531.   `sqrt(x^2+y^2)' except that it employs an algorithm that tries
  3532.   to avoid arithmetic overflow when `x' or `y' are large.
  3533.   If either argument is an array, an array of the corresponding values
  3534.   will be returned.
  3535.  
  3536.   If given a single array argument `x', the `hypot' function will
  3537.   compute `sqrt(sumsq(x))', where `sumsq(x)' computes the sum
  3538.   of the squares of the elements of `x'.
  3539.  
  3540.  SEE ALSO
  3541.   atan2, cos, atan, acosh, cosh, sum, sumsq
  3542.  
  3543. --------------------------------------------------------------
  3544.  
  3545. Imag
  3546.  
  3547.  SYNOPSIS
  3548.   Compute the imaginary part of a number
  3549.  
  3550.  USAGE
  3551.   i = Imag (z)
  3552.  
  3553.  DESCRIPTION
  3554.   The `Imag' function returns the imaginary part of a number.
  3555.   If its argument is an array, the `Imag' function will be applied to each
  3556.   element and the result returned as an array.
  3557.  
  3558.  SEE ALSO
  3559.   Real, Conj, abs
  3560.  
  3561. --------------------------------------------------------------
  3562.  
  3563. isinf
  3564.  
  3565.  SYNOPSIS
  3566.   Test for infinity
  3567.  
  3568.  USAGE
  3569.   y = isinf (x)
  3570.  
  3571.  DESCRIPTION
  3572.   This function returns 1 if x corresponds to an IEEE infinity, or 0
  3573.   otherwise. If the argument is an array, an array of the
  3574.   corresponding values will be returned.
  3575.  
  3576.  SEE ALSO
  3577.   isnan, _Inf
  3578.  
  3579. --------------------------------------------------------------
  3580.  
  3581. isnan
  3582.  
  3583.  SYNOPSIS
  3584.   isnan
  3585.  
  3586.  USAGE
  3587.   y = isnan (x)
  3588.  
  3589.  DESCRIPTION
  3590.   This function returns 1 if x corresponds to an IEEE NaN (Not a Number),
  3591.   or 0 otherwise.  If the argument is an array, an array of
  3592.   the corresponding values will be returned.
  3593.  
  3594.  SEE ALSO
  3595.   isinf, _NaN
  3596.  
  3597. --------------------------------------------------------------
  3598.  
  3599. log
  3600.  
  3601.  SYNOPSIS
  3602.   Compute the logarithm of a number
  3603.  
  3604.  USAGE
  3605.   y = log (x)
  3606.  
  3607.  DESCRIPTION
  3608.   The `log' function computes the natural logarithm of a number and
  3609.   returns the result.  If its argument is an array, the
  3610.   `log' function will be applied to each element and the result returned
  3611.   as an array.
  3612.  
  3613.  SEE ALSO
  3614.   cos, atan, acosh, cosh, log1p
  3615.  
  3616. --------------------------------------------------------------
  3617.  
  3618. log10
  3619.  
  3620.  SYNOPSIS
  3621.   Compute the base-10 logarithm of a number
  3622.  
  3623.  USAGE
  3624.   y = log10 (x)
  3625.  
  3626.  DESCRIPTION
  3627.   The `log10' function computes the base-10 logarithm of a number and
  3628.   returns the result.  If its argument is an array, the
  3629.   `log10' function will be applied to each element and the result returned
  3630.   as an array.
  3631.  
  3632.  SEE ALSO
  3633.   cos, atan, acosh, cosh
  3634.  
  3635. --------------------------------------------------------------
  3636.  
  3637. log1p
  3638.  
  3639.  SYNOPSIS
  3640.   Compute the logarithm of 1 plus a number
  3641.  
  3642.  USAGE
  3643.   y = log1p (x)
  3644.  
  3645.  DESCRIPTION
  3646.   The `log1p' function computes the natural logarithm of 1.0 plus
  3647.   `x' returns the result.  If its argument is an array, the
  3648.   `log1p' function will be applied to each element and the results
  3649.   returned as an array.
  3650.  
  3651.   This function should be used instead of `log(1+x)' to avoid
  3652.   numerical errors whenever `x' is close to 0.
  3653.  
  3654.  SEE ALSO
  3655.   log, expm1, cos, atan, acosh, cosh
  3656.  
  3657. --------------------------------------------------------------
  3658.  
  3659. _max
  3660.  
  3661.  SYNOPSIS
  3662.   Compute the maximum of two values
  3663.  
  3664.  USAGE
  3665.   z = _max (x,y)
  3666.  
  3667.  DESCRIPTION
  3668.   The `_max' function returns a floating point number equal to the
  3669.   maximum value of its two arguments.
  3670.   If either argument is an array, an array of the corresponding values
  3671.   will be returned.
  3672.  
  3673.  NOTES
  3674.   This function returns a floating point result even when both
  3675.   arguments are integers.
  3676.  
  3677.  SEE ALSO
  3678.   max, _min, min
  3679.  
  3680. --------------------------------------------------------------
  3681.  
  3682. _min
  3683.  
  3684.  SYNOPSIS
  3685.   Compute the minimum of two values
  3686.  
  3687.  USAGE
  3688.   z = _min (x,y)
  3689.  
  3690.  DESCRIPTION
  3691.   The `_min' function returns a floating point number equal to the
  3692.   minimum value of its two arguments.
  3693.   If either argument is an array, an array of the corresponding values
  3694.   will be returned.
  3695.  
  3696.  NOTES
  3697.   This function returns a floating point result even when both
  3698.   arguments are integers.
  3699.  
  3700.  SEE ALSO
  3701.   min, _max, max
  3702.  
  3703. --------------------------------------------------------------
  3704.  
  3705. mul2
  3706.  
  3707.  SYNOPSIS
  3708.   Multiply a number by 2
  3709.  
  3710.  USAGE
  3711.   y = mul2(x)
  3712.  
  3713.  DESCRIPTION
  3714.   The `mul2' function multiplies an arithmetic type by two and
  3715.   returns the result.  If its argument is an array, a new array will
  3716.   be created whose elements are obtained from the original array by
  3717.   using the `mul2' function.
  3718.  
  3719.  SEE ALSO
  3720.   sqr, abs
  3721.  
  3722. --------------------------------------------------------------
  3723.  
  3724. nint
  3725.  
  3726.  SYNOPSIS
  3727.   Round to the nearest integer
  3728.  
  3729.  USAGE
  3730.   i = nint(x)
  3731.  
  3732.  DESCRIPTION
  3733.   The `nint' rounds its argument to the nearest integer and
  3734.   returns the result.  If its argument is an array, a new array will
  3735.   be created whose elements are obtained from the original array
  3736.   elements by using the `nint' function.
  3737.  
  3738.  SEE ALSO
  3739.   round, floor, ceil
  3740.  
  3741. --------------------------------------------------------------
  3742.  
  3743. polynom
  3744.  
  3745.  SYNOPSIS
  3746.   Evaluate a polynomial
  3747.  
  3748.  USAGE
  3749.   Double_Type polynom([a0,a1,...aN], x [,use_factorial])
  3750.  
  3751.  DESCRIPTION
  3752.  The `polynom' function returns the value of the polynomial expression
  3753.  
  3754.      a0 + a1*x + a2*x^2 + ... + aN*x^N
  3755.  
  3756.  where the coefficients are given by an array of values
  3757.  `[a0,...,aN]'.  If `x' is an array, the function will
  3758.  return a corresponding array.  If the value of the optional
  3759.  `use_factorial' parameter is non-zero, then each term in the sum
  3760.  will be normalized by the corresponding factorial, i.e.,
  3761.  
  3762.      a0/0! + a1*x/1! + a2*x^2/2! + ... + aN*x^N/N!
  3763.  
  3764.  
  3765.  NOTES
  3766.   Prior to version 2.2, this function had a different calling syntax
  3767.   and and was less useful.
  3768.  
  3769.   The `polynom' function does not yet support complex-valued
  3770.   coefficients.
  3771.  
  3772.   For the case of a scalar value of `x' and a small degree
  3773.   polynomial, it is more efficient to use an explicit expression.
  3774.  
  3775.  SEE ALSO
  3776.   exp
  3777.  
  3778. --------------------------------------------------------------
  3779.  
  3780. Real
  3781.  
  3782.  SYNOPSIS
  3783.   Compute the real part of a number
  3784.  
  3785.  USAGE
  3786.   r = Real (z)
  3787.  
  3788.  DESCRIPTION
  3789.   The `Real' function returns the real part of a number. If its
  3790.   argument is an array, the `Real' function will be applied to
  3791.   each element and the result returned as an array.
  3792.  
  3793.  SEE ALSO
  3794.   Imag, Conj, abs
  3795.  
  3796. --------------------------------------------------------------
  3797.  
  3798. round
  3799.  
  3800.  SYNOPSIS
  3801.   Round to the nearest integral value
  3802.  
  3803.  USAGE
  3804.   y = round (x)
  3805.  
  3806.  DESCRIPTION
  3807.   This function rounds its argument to the nearest integral value and
  3808.   returns it as a floating point result. If the argument is an array,
  3809.   an array of the corresponding values will be returned.
  3810.  
  3811.  SEE ALSO
  3812.   floor, ceil, nint
  3813.  
  3814. --------------------------------------------------------------
  3815.  
  3816. set_float_format
  3817.  
  3818.  SYNOPSIS
  3819.   Set the format for printing floating point values.
  3820.  
  3821.  USAGE
  3822.   set_float_format (String_Type fmt)
  3823.  
  3824.  DESCRIPTION
  3825.   The `set_float_format' function is used to set the floating
  3826.   point format to be used when floating point numbers are printed.
  3827.   The routines that use this are the traceback routines and the
  3828.   `string' function, any anything based upon the `string'
  3829.   function. The default value is `"%S"', which causes the number
  3830.   to be displayed with enough significant digits such that
  3831.   `x==atof(string(x))'.
  3832.  
  3833.  EXAMPLE
  3834.  
  3835.      set_float_format ("%S");        % default
  3836.      s = string (PI);                %  --> s = "3.141592653589793"
  3837.      set_float_format ("%16.10f");
  3838.      s = string (PI);                %  --> s = "3.1415926536"
  3839.      set_float_format ("%10.6e");
  3840.      s = string (PI);                %  --> s = "3.141593e+00"
  3841.  
  3842.  
  3843.  SEE ALSO
  3844.   get_float_format, string, sprintf, atof, double
  3845.  
  3846. --------------------------------------------------------------
  3847.  
  3848. sign
  3849.  
  3850.  SYNOPSIS
  3851.   Compute the sign of a number
  3852.  
  3853.  USAGE
  3854.   y = sign(x)
  3855.  
  3856.  DESCRIPTION
  3857.   The `sign' function returns the sign of an arithmetic type.  If
  3858.   its argument is a complex number (Complex_Type), the
  3859.   `sign' will be applied to the imaginary part of the number.  If
  3860.   the argument is an array, a new array will be created whose elements
  3861.   are obtained from the original array by using the `sign'
  3862.   function.
  3863.  
  3864.   When applied to a real number or an integer, the `sign' function
  3865.   returns -1, 0, or `+1' according to whether the number is
  3866.   less than zero, equal to zero, or greater than zero, respectively.
  3867.  
  3868.  SEE ALSO
  3869.   abs
  3870.  
  3871. --------------------------------------------------------------
  3872.  
  3873. sin
  3874.  
  3875.  SYNOPSIS
  3876.   Compute the sine of a number
  3877.  
  3878.  USAGE
  3879.   y = sin (x)
  3880.  
  3881.  DESCRIPTION
  3882.   The `sin' function computes the sine of a number and
  3883.   returns the result.  If its argument is an array, the
  3884.   `sin' function will be applied to each element and the result returned
  3885.   as an array.
  3886.  
  3887.  SEE ALSO
  3888.   cos, atan, acosh, cosh
  3889.  
  3890. --------------------------------------------------------------
  3891.  
  3892. sinh
  3893.  
  3894.  SYNOPSIS
  3895.   Compute the hyperbolic sine of a number
  3896.  
  3897.  USAGE
  3898.   y = sinh (x)
  3899.  
  3900.  DESCRIPTION
  3901.   The `sinh' function computes the hyperbolic sine of a number and
  3902.   returns the result.  If its argument is an array, the
  3903.   `sinh' function will be applied to each element and the result returned
  3904.   as an array.
  3905.  
  3906.  SEE ALSO
  3907.   cos, atan, acosh, cosh
  3908.  
  3909. --------------------------------------------------------------
  3910.  
  3911. sqr
  3912.  
  3913.  SYNOPSIS
  3914.   Compute the square of a number
  3915.  
  3916.  USAGE
  3917.   y = sqr(x)
  3918.  
  3919.  DESCRIPTION
  3920.   The `sqr' function returns the square of an arithmetic type.  If its
  3921.   argument is a complex number (Complex_Type), then it returns
  3922.   the square of the modulus.  If the argument is an array, a new array
  3923.   will be created whose elements are obtained from the original array
  3924.   by using the `sqr' function.
  3925.  
  3926.  NOTES
  3927.   For real scalar numbers, using `x*x' instead of `sqr(x)'
  3928.   will result in faster executing code.  However, if `x' is an
  3929.   array, then `sqr(x)' will execute faster.
  3930.  
  3931.  SEE ALSO
  3932.   abs, mul2
  3933.  
  3934. --------------------------------------------------------------
  3935.  
  3936. sqrt
  3937.  
  3938.  SYNOPSIS
  3939.   Compute the square root of a number
  3940.  
  3941.  USAGE
  3942.   y = sqrt (x)
  3943.  
  3944.  DESCRIPTION
  3945.   The `sqrt' function computes the square root of a number and
  3946.   returns the result.  If its argument is an array, the
  3947.   `sqrt' function will be applied to each element and the result returned
  3948.   as an array.
  3949.  
  3950.  SEE ALSO
  3951.   sqr, cos, atan, acosh, cosh
  3952.  
  3953. --------------------------------------------------------------
  3954.  
  3955. tan
  3956.  
  3957.  SYNOPSIS
  3958.   Compute the tangent of a number
  3959.  
  3960.  USAGE
  3961.   y = tan (x)
  3962.  
  3963.  DESCRIPTION
  3964.   The `tan' function computes the tangent of a number and
  3965.   returns the result.  If its argument is an array, the
  3966.   `tan' function will be applied to each element and the result returned
  3967.   as an array.
  3968.  
  3969.  SEE ALSO
  3970.   cos, atan, acosh, cosh
  3971.  
  3972. --------------------------------------------------------------
  3973.  
  3974. tanh
  3975.  
  3976.  SYNOPSIS
  3977.   Compute the hyperbolic tangent of a number
  3978.  
  3979.  USAGE
  3980.   y = tanh (x)
  3981.  
  3982.  DESCRIPTION
  3983.   The `tanh' function computes the hyperbolic tangent of a number and
  3984.   returns the result.  If its argument is an array, the
  3985.   `tanh' function will be applied to each element and the result returned
  3986.   as an array.
  3987.  
  3988.  SEE ALSO
  3989.   cos, atan, acosh, cosh
  3990.  
  3991. --------------------------------------------------------------
  3992.  
  3993. _ispos
  3994.  
  3995.  SYNOPSIS
  3996.   Test if a number is greater than 0
  3997.  
  3998.  USAGE
  3999.   Char_Type _ispos(x)
  4000.  
  4001.  DESCRIPTION
  4002.   This function returns 1 if a number is greater than 0, and zero
  4003.   otherwise.  If the argument is an array, then the corresponding
  4004.   array of boolean (Char_Type) values will be returned.
  4005.  
  4006.  SEE ALSO
  4007.   _isneg, _isnonneg
  4008.  
  4009. --------------------------------------------------------------
  4010.  
  4011. _isneg
  4012.  
  4013.  SYNOPSIS
  4014.   Test if a number is less than 0
  4015.  
  4016.  USAGE
  4017.   Char_Type _isneg(x)
  4018.  
  4019.  DESCRIPTION
  4020.   This function returns 1 if a number is less than 0, and zero
  4021.   otherwise.  If the argument is an array, then the corresponding
  4022.   array of boolean (Char_Type) values will be returned.
  4023.  
  4024.  SEE ALSO
  4025.   _ispos, _isnonneg
  4026.  
  4027. --------------------------------------------------------------
  4028.  
  4029. _isnonneg
  4030.  
  4031.  SYNOPSIS
  4032.   Test if a number is greater than or equal to 0
  4033.  
  4034.  USAGE
  4035.   Char_Type _isnonneg(x)
  4036.  
  4037.  DESCRIPTION
  4038.   This function returns 1 if a number is greater or equal to 0, and zero
  4039.   otherwise.  If the argument is an array, then the corresponding
  4040.   array of boolean (Char_Type) values will be returned.
  4041.  
  4042.  SEE ALSO
  4043.   _isneg, _isnonneg
  4044.  
  4045. --------------------------------------------------------------
  4046.  
  4047. errno
  4048.  
  4049.  SYNOPSIS
  4050.   Error code set by system functions
  4051.  
  4052.  USAGE
  4053.   Int_Type errno
  4054.  
  4055.  DESCRIPTION
  4056.   A system function can fail for a variety of reasons.  For example, a
  4057.   file operation may fail because lack of disk space, or the process
  4058.   does not have permission to perform the operation.  Such functions
  4059.   will return -1 and set the variable `errno' to an error
  4060.   code describing the reason for failure.
  4061.  
  4062.   Particular values of `errno' may be specified by the following
  4063.   symbolic constants (read-only variables) and the corresponding
  4064.   `errno_string' value:
  4065.  
  4066.      EPERM            "Not owner"
  4067.      ENOENT           "No such file or directory"
  4068.      ESRCH            "No such process"
  4069.      ENXIO            "No such device or address"
  4070.      ENOEXEC          "Exec format error"
  4071.      EBADF            "Bad file number"
  4072.      ECHILD           "No children"
  4073.      ENOMEM           "Not enough core"
  4074.      EACCES           "Permission denied"
  4075.      EFAULT           "Bad address"
  4076.      ENOTBLK          "Block device required"
  4077.      EBUSY            "Mount device busy"
  4078.      EEXIST           "File exists"
  4079.      EXDEV            "Cross-device link"
  4080.      ENODEV           "No such device"
  4081.      ENOTDIR          "Not a directory"
  4082.      EISDIR           "Is a directory"
  4083.      EINVAL           "Invalid argument"
  4084.      ENFILE           "File table overflow"
  4085.      EMFILE           "Too many open files"
  4086.      ENOTTY           "Not a typewriter"
  4087.      ETXTBSY          "Text file busy"
  4088.      EFBIG            "File too large"
  4089.      ENOSPC           "No space left on device"
  4090.      ESPIPE           "Illegal seek"
  4091.      EROFS            "Read-only file system"
  4092.      EMLINK           "Too many links"
  4093.      EPIPE            "Broken pipe"
  4094.      ELOOP            "Too many levels of symbolic links"
  4095.      ENAMETOOLONG     "File name too long"
  4096.  
  4097.  
  4098.  EXAMPLE
  4099.   The `mkdir' function will attempt to create a directory.  If
  4100.   that directory already exists, the function will fail and set
  4101.   `errno' to EEXIST.
  4102.  
  4103.     define create_dir (dir)
  4104.     {
  4105.        if (0 == mkdir (dir)) return;
  4106.        if (errno != EEXIST)
  4107.          throw IOError, sprintf ("mkdir %s failed: %s",
  4108.                                   dir, errno_string (errno));
  4109.     }
  4110.  
  4111.  
  4112.  SEE ALSO
  4113.   errno_string, error, mkdir
  4114.  
  4115. --------------------------------------------------------------
  4116.  
  4117. errno_string
  4118.  
  4119.  SYNOPSIS
  4120.   Return a string describing an errno.
  4121.  
  4122.  USAGE
  4123.   String_Type errno_string ( [Int_Type err ])
  4124.  
  4125.  DESCRIPTION
  4126.   The `errno_string' function returns a string describing the
  4127.   integer errno code `err'.  If the `err' parameter is
  4128.   omitted, the current value of `errno' will be used. See the
  4129.   description for `errno' for more information.
  4130.  
  4131.  EXAMPLE
  4132.   The `errno_string' function may be used as follows:
  4133.  
  4134.     define sizeof_file (file)
  4135.     {
  4136.        variable st = stat_file (file);
  4137.        if (st == NULL)
  4138.          throw IOError, sprintf ("%s: %s", file, errno_string (errno));
  4139.        return st.st_size;
  4140.     }
  4141.  
  4142.  
  4143.  SEE ALSO
  4144.   errno, stat_file
  4145.  
  4146. --------------------------------------------------------------
  4147.  
  4148. error
  4149.  
  4150.  SYNOPSIS
  4151.   Generate an error condition (deprecated)
  4152.  
  4153.  USAGE
  4154.   error (String_Type msg
  4155.  
  4156.  DESCRIPTION
  4157.   This function has been deprecated in favor of `throw'.
  4158.  
  4159.   The `error' function generates a S-Lang `RunTimeError'
  4160.   exception. It takes a single string parameter which is displayed on
  4161.   the stderr output device.
  4162.  
  4163.  EXAMPLE
  4164.  
  4165.     define add_txt_extension (file)
  4166.     {
  4167.        if (typeof (file) != String_Type)
  4168.          error ("add_extension: parameter must be a string");
  4169.        file += ".txt";
  4170.        return file;
  4171.     }
  4172.  
  4173.  
  4174.  SEE ALSO
  4175.   verror, message
  4176.  
  4177. --------------------------------------------------------------
  4178.  
  4179. __get_exception_info
  4180.  
  4181.  SYNOPSIS
  4182.   Get information about the current exception
  4183.  
  4184.  USAGE
  4185.   Struct_Type __get_exception_info ()
  4186.  
  4187.  DESCRIPTION
  4188.  This function returns information about the currently active
  4189.  exception in the form as a structure with the
  4190.  following fields:
  4191.  
  4192.     error            The current exception, e.g., RunTimeError
  4193.     descr            A description of the exception
  4194.     file             Name of the file generating the exception
  4195.     line             Line number where the exception originated
  4196.     function         Function where the exception originated
  4197.     object           A user-defined object thrown by the exception
  4198.     message          A user-defined message
  4199.     traceback        Traceback messages
  4200.  
  4201.  If no exception is active, NULL will be returned.
  4202.  
  4203.  This same information may also be obtained via the optional argument
  4204.  to the `try' statement:
  4205.  
  4206.      variable e = NULL;
  4207.      try (e)
  4208.        {
  4209.           do_something ();
  4210.        }
  4211.      finally
  4212.        {
  4213.           if (e != NULL)
  4214.             vmessage ("An error occured: %s", e.message);
  4215.        }
  4216.  
  4217.  
  4218.  SEE ALSO
  4219.   error
  4220.  
  4221. --------------------------------------------------------------
  4222.  
  4223. message
  4224.  
  4225.  SYNOPSIS
  4226.   Print a string onto the message device
  4227.  
  4228.  USAGE
  4229.   message (String_Type s
  4230.  
  4231.  DESCRIPTION
  4232.   The `message' function will print the string specified by
  4233.   `s' onto the message device.
  4234.  
  4235.  EXAMPLE
  4236.  
  4237.      define print_current_time ()
  4238.      {
  4239.        message (time ());
  4240.      }
  4241.  
  4242.  
  4243.  NOTES
  4244.   The message device will depend upon the application.  For example,
  4245.   the output message device for the jed editor corresponds to the
  4246.   line at the bottom of the display window.  The default message
  4247.   device is the standard output device.
  4248.  
  4249.  SEE ALSO
  4250.   vmessage, sprintf, error
  4251.  
  4252. --------------------------------------------------------------
  4253.  
  4254. new_exception
  4255.  
  4256.  SYNOPSIS
  4257.   Create a new exception
  4258.  
  4259.  USAGE
  4260.   new_exception (String_Type name, Int_Type baseclass, String_Type descr)
  4261.  
  4262.  DESCRIPTION
  4263.   This function creates a new exception called `name' subclassed
  4264.   upon `baseclass'.  The description of the exception is
  4265.   specified by `descr'.
  4266.  
  4267.  EXAMPLE
  4268.  
  4269.   new_exception ("MyError", RunTimeError, "My very own error");
  4270.   try
  4271.     {
  4272.        if (something_is_wrong ())
  4273.          throw MyError;
  4274.     }
  4275.   catch RunTimeError;
  4276.  
  4277.   In this case, catching `RunTimeError' will also catch
  4278.   `MyError' since it is a subclass of `RunTimeError'.
  4279.  
  4280.  SEE ALSO
  4281.   error, verror
  4282.  
  4283. --------------------------------------------------------------
  4284.  
  4285. usage
  4286.  
  4287.  SYNOPSIS
  4288.   Generate a usage error
  4289.  
  4290.  USAGE
  4291.   usage (String_Type msg)
  4292.  
  4293.  DESCRIPTION
  4294.   The `usage' function generates a `UsageError' exception and
  4295.   displays `msg' to the message device.
  4296.  
  4297.  EXAMPLE
  4298.   Suppose that a function called `plot' plots an array of `x' and
  4299.   `y' values.  Then such a function could be written to issue a
  4300.   usage message if the wrong number of arguments was passed:
  4301.  
  4302.     define plot ()
  4303.     {
  4304.        variable x, y;
  4305.  
  4306.        if (_NARGS != 2)
  4307.          usage ("plot (x, y)");
  4308.  
  4309.        (x, y) = ();
  4310.        % Now do the hard part
  4311.           .
  4312.           .
  4313.     }
  4314.  
  4315.  
  4316.  SEE ALSO
  4317.   error, message
  4318.  
  4319. --------------------------------------------------------------
  4320.  
  4321. verror
  4322.  
  4323.  SYNOPSIS
  4324.   Generate an error condition (deprecated)
  4325.  
  4326.  USAGE
  4327.   verror (String_Type fmt, ...)
  4328.  
  4329.  DESCRIPTION
  4330.   This function has been deprecated in favor or `throw'.
  4331.  
  4332.   The `verror' function performs the same role as the `error'
  4333.   function.  The only difference is that instead of a single string
  4334.   argument, `verror' takes a sprintf style argument list.
  4335.  
  4336.  EXAMPLE
  4337.  
  4338.     define open_file (file)
  4339.     {
  4340.        variable fp;
  4341.  
  4342.        fp = fopen (file, "r");
  4343.        if (fp == NULL) verror ("Unable to open %s", file);
  4344.        return fp;
  4345.     }
  4346.  
  4347.  
  4348.  NOTES
  4349.   In the current implementation, the `verror' function is not an
  4350.   intrinsic function.  Rather it is a predefined S-Lang function using
  4351.   a combination of `sprintf' and `error'.
  4352.  
  4353.   To generate a specific exception, a `throw' statement should be
  4354.   used.  In fact, a `throw' statement such as:
  4355.  
  4356.      if (fp == NULL)
  4357.        throw OpenError, "Unable to open $file"$;
  4358.  
  4359.   is preferable to the use of `verror' in the above example.
  4360.  
  4361.  SEE ALSO
  4362.   error, Sprintf, vmessage
  4363.  
  4364. --------------------------------------------------------------
  4365.  
  4366. vmessage
  4367.  
  4368.  SYNOPSIS
  4369.   Print a formatted string onto the message device
  4370.  
  4371.  USAGE
  4372.   vmessage (String_Type fmt, ...)
  4373.  
  4374.  DESCRIPTION
  4375.   The `vmessage' function formats a sprintf style argument list
  4376.   and displays the resulting string onto the message device.
  4377.  
  4378.  NOTES
  4379.   In the current implementation, the `vmessage' function is not an
  4380.   intrinsic function.  Rather it is a predefined S-Lang function using
  4381.   a combination of `Sprintf' and `message'.
  4382.  
  4383.  SEE ALSO
  4384.   message, sprintf, Sprintf, verror
  4385.  
  4386. --------------------------------------------------------------
  4387.  
  4388. _auto_declare
  4389.  
  4390.  SYNOPSIS
  4391.   Set automatic variable declaration mode
  4392.  
  4393.  USAGE
  4394.   Integer_Type _auto_declare
  4395.  
  4396.  DESCRIPTION
  4397.   The `_auto_declare' variable may be used to have undefined
  4398.   variable implicitly declared.  If set to zero, any
  4399.   variable must be declared with a `variable' declaration before it
  4400.   can be used.  If set to one, then any undeclared variable will be
  4401.   declared as a `static' variable.
  4402.  
  4403.   The `_auto_declare' variable is local to each compilation unit and
  4404.   setting its value in one unit has no effect upon its value in other
  4405.   units.   The value of this variable has no effect upon the variables
  4406.   in a function.
  4407.  
  4408.  EXAMPLE
  4409.   The following code will not compile if `X' not been
  4410.   declared:
  4411.  
  4412.     X = 1;
  4413.  
  4414.   However,
  4415.  
  4416.     _auto_declare = 1;   % declare variables as static.
  4417.     X = 1;
  4418.  
  4419.   is equivalent to
  4420.  
  4421.     static variable X = 1;
  4422.  
  4423.  
  4424.  NOTES
  4425.   This variable should be used sparingly and is intended primarily for
  4426.   interactive applications where one types S-Lang commands at a
  4427.   prompt.
  4428.  
  4429. --------------------------------------------------------------
  4430.  
  4431. __class_id
  4432.  
  4433.  SYNOPSIS
  4434.   Return the class-id of a specified type
  4435.  
  4436.  USAGE
  4437.   Int_Type __class_id (DataType_Type type)
  4438.  
  4439.  DESCRIPTION
  4440.   This function returns the internal class-id of a specified data type.
  4441.  
  4442.  SEE ALSO
  4443.   typeof, _typeof, __class_type, __datatype
  4444.  
  4445. --------------------------------------------------------------
  4446.  
  4447. __class_type
  4448.  
  4449.  SYNOPSIS
  4450.   Return the class-type of a specified type
  4451.  
  4452.  USAGE
  4453.   Int_Type __class_type (DataType_Type type))
  4454.  
  4455.  DESCRIPTION
  4456.   Internally S-Lang objects are classified according to four types:
  4457.   scalar, vector, pointer, and memory managed types.  For example, an
  4458.   integer is implemented as a scalar, a complex number as a vector,
  4459.   and a string is represented as a pointer.  The `__class_type'
  4460.   function returns an integer representing the class-type associated
  4461.   with the specified data type. Specifically, it returns:
  4462.  
  4463.        0    memory-managed
  4464.        1    scalar
  4465.        2    vector
  4466.        3    pointer
  4467.  
  4468.  
  4469.  SEE ALSO
  4470.   typeof, _typeof, __class_id, __datatype
  4471.  
  4472. --------------------------------------------------------------
  4473.  
  4474. current_namespace
  4475.  
  4476.  SYNOPSIS
  4477.   Get the name of the current namespace
  4478.  
  4479.  USAGE
  4480.   String_Type current_namespace ()
  4481.  
  4482.  DESCRIPTION
  4483.    The `current_namespace' function returns the name of the
  4484.    static namespace associated with the compilation unit.  If there is
  4485.    no such namespace associated with the compilation unit, then the
  4486.    empty string `""' will be returned.
  4487.  
  4488.  SEE ALSO
  4489.   implements, use_namespace, import, evalfile
  4490.  
  4491. --------------------------------------------------------------
  4492.  
  4493. __datatype
  4494.  
  4495.  SYNOPSIS
  4496.   Get the DataType_Type for a specified internal class-id
  4497.  
  4498.  USAGE
  4499.   DataType_Type __datatype (Int_Type id)
  4500.  
  4501.  DESCRIPTION
  4502.  This function is the inverse of __class_type in the sense that it
  4503.  returns the DataType_Type for the specified class-id.  If no
  4504.  such class exists, the function will return NULL.
  4505.  
  4506.  NOTES
  4507.  One should not expect distinct interpreter instances to always return
  4508.  the same value for a dynamically assigned class-id such as one
  4509.  defined by a module or one stemming from a `typedef' statement.
  4510.  
  4511.  SEE ALSO
  4512.   __class_id, __class_type, typeof
  4513.  
  4514. --------------------------------------------------------------
  4515.  
  4516. _eqs
  4517.  
  4518.  SYNOPSIS
  4519.   Test for equality of two objects
  4520.  
  4521.  USAGE
  4522.   Int_Type _eqs (a, b)
  4523.  
  4524.  DESCRIPTION
  4525.   This function tests its two arguments for equality and returns 1 if
  4526.   they are equal or 0 otherwise. What it means to be equal depends
  4527.   upon the data types of the objects being compared.  If the types are
  4528.   numeric, they are regarded as equal if their numerical values are
  4529.   equal.  If they are arrays, then they are equal if they have the
  4530.   same shape with equal elements. If they are structures, then they
  4531.   are equal if they contain identical fields, and the corresponding
  4532.   values are equal.
  4533.  
  4534.  EXAMPLE
  4535.    _eqs (1, 1)             ===> 1
  4536.    _eqs (1, 1.0)           ===> 1
  4537.    _eqs ("a", 1)           ===> 0
  4538.    _eqs ([1,2], [1.0,2.0]) ===> 1
  4539.  
  4540.  SEE ALSO
  4541.   typeof, _eqs, __get_reference, __is_callable
  4542.  
  4543.  NOTES
  4544.    For testing sameness, use `__is_same'.
  4545.  
  4546. --------------------------------------------------------------
  4547.  
  4548. getenv
  4549.  
  4550.  SYNOPSIS
  4551.   Get the value of an environment variable
  4552.  
  4553.  USAGE
  4554.   String_Type getenv(String_Type var)
  4555.  
  4556.  DESCRIPTION
  4557.    The `getenv' function returns a string that represents the
  4558.    value of an environment variable `var'.  It will return
  4559.    NULL if there is no environment variable whose name is given
  4560.    by `var'.
  4561.  
  4562.  EXAMPLE
  4563.  
  4564.     if (NULL != getenv ("USE_COLOR"))
  4565.       {
  4566.         set_color ("normal", "white", "blue");
  4567.         set_color ("status", "black", "gray");
  4568.         USE_ANSI_COLORS = 1;
  4569.       }
  4570.  
  4571.  
  4572.  SEE ALSO
  4573.   putenv, strlen, is_defined
  4574.  
  4575. --------------------------------------------------------------
  4576.  
  4577. __get_reference
  4578.  
  4579.  SYNOPSIS
  4580.   Get a reference to a global object
  4581.  
  4582.  USAGE
  4583.   Ref_Type __get_reference (String_Type nm)
  4584.  
  4585.  DESCRIPTION
  4586.   This function returns a reference to a global variable or function
  4587.   whose name is specified by `nm'.  If no such object exists, it
  4588.   returns NULL, otherwise it returns a reference.
  4589.  
  4590.  EXAMPLE
  4591.    Consider the function:
  4592.  
  4593.     define runhooks (hook)
  4594.     {
  4595.        variable f;
  4596.        f = __get_reference (hook);
  4597.        if (f != NULL)
  4598.          @f ();
  4599.     }
  4600.  
  4601.    This function could be called from another S-Lang function to allow
  4602.    customization of that function, e.g., if the function represents a
  4603.    jed editor mode, the hook could be called to setup keybindings for
  4604.    the mode.
  4605.  
  4606.  SEE ALSO
  4607.   is_defined, typeof, eval, autoload, __is_initialized, __uninitialize
  4608.  
  4609. --------------------------------------------------------------
  4610.  
  4611. implements
  4612.  
  4613.  SYNOPSIS
  4614.   Create a new static namespace
  4615.  
  4616.  USAGE
  4617.   implements (String_Type name)
  4618.  
  4619.  DESCRIPTION
  4620.   The `implements' function may be used to create a new static
  4621.   namespace and have it associated with the current compilation unit.
  4622.   If a namespace with the specified name already exists, a
  4623.   `NamespaceError' exception will be thrown.
  4624.  
  4625.   In addition to creating a new static namespace and associating it
  4626.   with the compilation unit, the function will also create a new
  4627.   private namespace.  As a result, any symbols in the previous private
  4628.   namespace will be no longer be accessable.  For this reason, it is
  4629.   recommended that this function should be used before any private
  4630.   symbols have been created.
  4631.  
  4632.  EXAMPLE
  4633.   Suppose that some file `t.sl' contains:
  4634.  
  4635.      implements ("My");
  4636.      define message (x)
  4637.      {
  4638.         Global->message ("My's message: $x"$);
  4639.      }
  4640.      message ("hello");
  4641.  
  4642.   will produce `"My's message: hello"'.  This `message'
  4643.   function may be accessed from outside the namespace via:
  4644.  
  4645.     My->message ("hi");
  4646.  
  4647.  
  4648.  NOTES
  4649.   Since `message' is an intrinsic function, it is public and may
  4650.   not be redefined in the public namespace.
  4651.  
  4652.   The `implements' function should rarely be used.  It is
  4653.   preferable to allow a static namespace to be associated with a
  4654.   compilation unit using, e.g., `evalfile'.
  4655.  
  4656.  SEE ALSO
  4657.   use_namespace, current_namespace, import
  4658.  
  4659. --------------------------------------------------------------
  4660.  
  4661. __is_callable
  4662.  
  4663.  SYNOPSIS
  4664.   Determine whether or not an object is callable
  4665.  
  4666.  USAGE
  4667.   Int_Type __is_callable (obj)
  4668.  
  4669.  DESCRIPTION
  4670.   This function may be used to determine if an object is callable by
  4671.   dereferencing the object.  It returns 1 if the argument is callable,
  4672.   or zero otherwise.
  4673.  
  4674.  EXAMPLE
  4675.    __is_callable (7)      ==> 0
  4676.    __is_callable (&sin)   ==> 1
  4677.    a = [&sin];
  4678.    __is_callable (a[0])   ==> 1
  4679.    __is_callable (&a[0])  ==> 0
  4680.  
  4681.  SEE ALSO
  4682.   __is_numeric, is_defined
  4683.  
  4684. --------------------------------------------------------------
  4685.  
  4686. __is_numeric
  4687.  
  4688.  SYNOPSIS
  4689.   Determine whether or not an object is a numeric type
  4690.  
  4691.  USAGE
  4692.   Int_Type __is_numeric (obj)
  4693.  
  4694.  DESCRIPTION
  4695.   This function may be used to determine if an object represents a
  4696.   numeric type.  It returns 0 if the argument is non-numeric, 1 if it
  4697.   is an integer, 2 if a floating point number, and 3 if it is complex.
  4698.   If the argument is an array, then the array type will be used for
  4699.   the test.
  4700.  
  4701.  EXAMPLE
  4702.    __is_numeric ("foo");  ==> 0
  4703.    __is_numeric ("0");    ==> 0
  4704.    __is_numeric (0);      ==> 1
  4705.    __is_numeric (PI);     ==> 2
  4706.    __is_numeric (2j);     ==> 3
  4707.    __is_numeric ([1,2]);  ==> 1
  4708.    __is_numeric ({1,2});  ==> 0
  4709.  
  4710.  SEE ALSO
  4711.   typeof, __is_datatype_numeric
  4712.  
  4713. --------------------------------------------------------------
  4714.  
  4715. __is_datatype_numeric
  4716.  
  4717.  SYNOPSIS
  4718.   Determine whether or not a type is a numeric type
  4719.  
  4720.  USAGE
  4721.   Int_Type __is_datatype_numeric (DataType_Type type)
  4722.  
  4723.  DESCRIPTION
  4724.   This function may be used to determine if the specified datatype
  4725.   represents a numeric type.  It returns 0 if the datatype does not
  4726.   represents a numeric type; otherwise it returns 1 for an
  4727.   integer type, 2 for a floating point type, and 3 for a complex type.
  4728.  
  4729.  SEE ALSO
  4730.   typeof, __is_numeric, __is_callable
  4731.  
  4732. --------------------------------------------------------------
  4733.  
  4734. __is_same
  4735.  
  4736.  SYNOPSIS
  4737.   Test for sameness of two objects
  4738.  
  4739.  USAGE
  4740.   Int_Type __is_same (a, b)
  4741.  
  4742.  DESCRIPTION
  4743.   This function tests its two arguments for sameness and returns 1
  4744.   if they are the same, or 0 otherwise.  To be the same, the data type of
  4745.   the arguments must match and the values of the objects must
  4746.   reference the same underlying object.
  4747.  
  4748.  EXAMPLE
  4749.    __is_same (1, 1)         ===> 1
  4750.    __is_same (1, 1.0)       ===> 0
  4751.    __is_same ("a", 1)       ===> 0
  4752.    __is_same ([1,2], [1,2]) ===> 0
  4753.  
  4754.  SEE ALSO
  4755.   typeof, _eqs, __get_reference, __is_callable
  4756.  
  4757.  NOTES
  4758.    For testing equality, use `_eqs'.
  4759.  
  4760. --------------------------------------------------------------
  4761.  
  4762. putenv
  4763.  
  4764.  SYNOPSIS
  4765.   Add or change an environment variable
  4766.  
  4767.  USAGE
  4768.   putenv (String_Type s)
  4769.  
  4770.  DESCRIPTION
  4771.     This functions adds string `s' to the environment.  Typically,
  4772.     `s' should of the form `"name=value"'.  The function
  4773.     throws an `OSError' upon failure.
  4774.  
  4775.  NOTES
  4776.     This function may not be available on all systems.
  4777.  
  4778.  SEE ALSO
  4779.   getenv, sprintf
  4780.  
  4781. --------------------------------------------------------------
  4782.  
  4783. _slang_install_prefix
  4784.  
  4785.  SYNOPSIS
  4786.   S-Lang's installation prefix
  4787.  
  4788.  USAGE
  4789.   String_Type _slang_install_prefix
  4790.  
  4791.  DESCRIPTION
  4792.   The value of this variable is set at the S-Lang library's
  4793.   compilation time.  On Unix systems, the value corresponds to the
  4794.   value of the `prefix' variable in the Makefile.  For normal
  4795.   installations, the library itself will be located in the `lib'
  4796.   subdirectory of the `prefix' directory.
  4797.  
  4798.  NOTES
  4799.   The value of this variable may or may not have anything to do with
  4800.   where the slang library is located.  As such, it should be regarded
  4801.   as a hint.  A standard installation will have the `slsh'
  4802.   library files located in the `share/slsh' subdirectory of the
  4803.   installation prefix.
  4804.  
  4805.  SEE ALSO
  4806.   _slang_doc_dir
  4807.  
  4808. --------------------------------------------------------------
  4809.  
  4810. _slang_utf8_ok
  4811.  
  4812.  SYNOPSIS
  4813.   Test if the interpreter running in UTF-8 mode
  4814.  
  4815.  USAGE
  4816.   Int_Type _slang_utf8_ok
  4817.  
  4818.  DESCRIPTION
  4819.   If the value of this variable is non-zero, then the interpreter is
  4820.   running in UTF-8 mode.  In this mode, characters in strings are
  4821.   interpreted as variable length byte sequences according to the
  4822.   semantics of the UTF-8 encoding.
  4823.  
  4824.  NOTES
  4825.   When running in UTF-8 mode, one must be careful not to confuse a
  4826.   character with a byte.  For example, in this mode the `strlen'
  4827.   function returns the number of characters in a string which may be
  4828.   different than the number of bytes.  The latter information may be
  4829.   obtained by the `strbytelen' function.
  4830.  
  4831.  SEE ALSO
  4832.   strbytelen, strlen, strcharlen
  4833.  
  4834. --------------------------------------------------------------
  4835.  
  4836. __uninitialize
  4837.  
  4838.  SYNOPSIS
  4839.   Uninitialize a variable
  4840.  
  4841.  USAGE
  4842.   __uninitialize (Ref_Type x)
  4843.  
  4844.  DESCRIPTION
  4845.   The `__uninitialize' function may be used to uninitialize the
  4846.   variable referenced by the parameter `x'.
  4847.  
  4848.  EXAMPLE
  4849.   The following two lines are equivalent:
  4850.  
  4851.      () = __tmp(z);
  4852.      __uninitialize (&z);
  4853.  
  4854.  
  4855.  SEE ALSO
  4856.   __tmp, __is_initialized
  4857.  
  4858. --------------------------------------------------------------
  4859.  
  4860. use_namespace
  4861.  
  4862.  SYNOPSIS
  4863.   Change to another namespace
  4864.  
  4865.  USAGE
  4866.   use_namespace (String_Type name)
  4867.  
  4868.  DESCRIPTION
  4869.    The `use_namespace' function changes the current static namespace to
  4870.    the one specified by the parameter.  If the specified namespace
  4871.    does not exist, a `NamespaceError' exception will be generated.
  4872.  
  4873.  SEE ALSO
  4874.   implements, current_namespace, import
  4875.  
  4876. --------------------------------------------------------------
  4877.  
  4878. path_basename
  4879.  
  4880.  SYNOPSIS
  4881.   Get the basename part of a filename
  4882.  
  4883.  USAGE
  4884.   String_Type path_basename (String_Type filename)
  4885.  
  4886.  DESCRIPTION
  4887.    The `path_basename' function returns the basename associated
  4888.    with the `filename' parameter.  The basename is the non-directory
  4889.    part of the filename, e.g., on unix `c' is the basename of
  4890.    `/a/b/c'.
  4891.  
  4892.  SEE ALSO
  4893.   path_dirname, path_extname, path_concat, path_is_absolute
  4894.  
  4895. --------------------------------------------------------------
  4896.  
  4897. path_basename_sans_extname
  4898.  
  4899.  SYNOPSIS
  4900.   Get the basename part of a filename but without the extension
  4901.  
  4902.  USAGE
  4903.   String_Type path_basename_sans_extname (String_Type path)
  4904.  
  4905.  DESCRIPTION
  4906.    The `path_basename_sans_extname' function returns the basename
  4907.    associated with the `filename' parameter, omitting the
  4908.    extension if present.  The basename is the non-directory part of
  4909.    the filename, e.g., on unix `c' is the basename of
  4910.    `/a/b/c'.
  4911.  
  4912.  SEE ALSO
  4913.   path_dirname, path_basename, path_extname, path_concat, path_is_absolute
  4914.  
  4915. --------------------------------------------------------------
  4916.  
  4917. path_concat
  4918.  
  4919.  SYNOPSIS
  4920.   Combine elements of a filename
  4921.  
  4922.  USAGE
  4923.   String_Type path_concat (String_Type dir, String_Type basename)
  4924.  
  4925.  DESCRIPTION
  4926.    The `path_concat' function combines the arguments `dir' and
  4927.    `basename' to produce a filename.  For example, on Unix if
  4928.    `dir' is `x/y' and `basename' is `z', then the
  4929.    function will return `x/y/z'.
  4930.  
  4931.  SEE ALSO
  4932.   path_dirname, path_basename, path_extname, path_is_absolute
  4933.  
  4934. --------------------------------------------------------------
  4935.  
  4936. path_dirname
  4937.  
  4938.  SYNOPSIS
  4939.   Get the directory name part of a filename
  4940.  
  4941.  USAGE
  4942.   String_Type path_dirname (String_Type filename)
  4943.  
  4944.  DESCRIPTION
  4945.    The `path_dirname' function returns the directory name
  4946.    associated with a specified filename.
  4947.  
  4948.  NOTES
  4949.    On systems that include a drive specifier as part of the filename,
  4950.    the value returned by this function will also include the drive
  4951.    specifier.
  4952.  
  4953.  SEE ALSO
  4954.   path_basename, path_extname, path_concat, path_is_absolute
  4955.  
  4956. --------------------------------------------------------------
  4957.  
  4958. path_extname
  4959.  
  4960.  SYNOPSIS
  4961.   Return the extension part of a filename
  4962.  
  4963.  USAGE
  4964.   String_Type path_extname (String_Type filename)
  4965.  
  4966.  DESCRIPTION
  4967.    The `path_extname' function returns the extension portion of the
  4968.    specified filename.  If an extension is present, this function will
  4969.    also include the dot as part of the extension, e.g., if `filename'
  4970.    is `"file.c"', then this function will return `".c"'.  If no
  4971.    extension is present, the function returns an empty string `""'.
  4972.  
  4973.  NOTES
  4974.    Under VMS, the file version number is not returned as part of the
  4975.    extension.
  4976.  
  4977.  SEE ALSO
  4978.   path_sans_extname, path_dirname, path_basename, path_concat, path_is_absolute
  4979.  
  4980. --------------------------------------------------------------
  4981.  
  4982. path_get_delimiter
  4983.  
  4984.  SYNOPSIS
  4985.   Get the value of a search-path delimiter
  4986.  
  4987.  USAGE
  4988.   Char_Type path_get_delimiter ()
  4989.  
  4990.  DESCRIPTION
  4991.   This function returns the value of the character used to delimit
  4992.   fields of a search-path.
  4993.  
  4994.  SEE ALSO
  4995.   set_slang_load_path, get_slang_load_path
  4996.  
  4997. --------------------------------------------------------------
  4998.  
  4999. path_is_absolute
  5000.  
  5001.  SYNOPSIS
  5002.   Determine whether or not a filename is absolute
  5003.  
  5004.  USAGE
  5005.   Int_Type path_is_absolute (String_Type filename)
  5006.  
  5007.  DESCRIPTION
  5008.    The `path_is_absolute' function will return non-zero is
  5009.    `filename' refers to an absolute filename, otherwise it returns zero.
  5010.  
  5011.  SEE ALSO
  5012.   path_dirname, path_basename, path_extname, path_concat
  5013.  
  5014. --------------------------------------------------------------
  5015.  
  5016. path_sans_extname
  5017.  
  5018.  SYNOPSIS
  5019.   Strip the extension from a filename
  5020.  
  5021.  USAGE
  5022.   String_Type path_sans_extname (String_Type filename)
  5023.  
  5024.  DESCRIPTION
  5025.   The `path_sans_extname' function removes the file name extension
  5026.   (including the dot) from the filename and returns the result.
  5027.  
  5028.  SEE ALSO
  5029.   path_basename_sans_extname, path_extname, path_basename, path_dirname, path_concat
  5030.  
  5031. --------------------------------------------------------------
  5032.  
  5033. close
  5034.  
  5035.  SYNOPSIS
  5036.   Close an open file descriptor
  5037.  
  5038.  USAGE
  5039.   Int_Type close (FD_Type fd)
  5040.  
  5041.  DESCRIPTION
  5042.   The `close' function is used to close and open file descriptor
  5043.   created by the `open' function.  Upon success 0 is returned,
  5044.   otherwise the function returns -1 and sets `errno' accordingly.
  5045.  
  5046.  SEE ALSO
  5047.   open, fclose, read, write
  5048.  
  5049. --------------------------------------------------------------
  5050.  
  5051. dup_fd
  5052.  
  5053.  SYNOPSIS
  5054.   Duplicate a file descriptor
  5055.  
  5056.  USAGE
  5057.   FD_Type dup_fd (FD_Type fd)
  5058.  
  5059.  DESCRIPTION
  5060.   The `dup_fd' function duplicates a specified file descriptor and
  5061.   returns the duplicate.  If the function fails, NULL will be
  5062.   returned and `errno' set accordingly.
  5063.  
  5064.  NOTES
  5065.   This function is essentially a wrapper around the POSIX `dup'
  5066.   function.
  5067.  
  5068.  SEE ALSO
  5069.   open, close
  5070.  
  5071. --------------------------------------------------------------
  5072.  
  5073. _fileno
  5074.  
  5075.  SYNOPSIS
  5076.   Get the underlying integer file descriptor
  5077.  
  5078.  USAGE
  5079.   Int_Type fileno (File_Type|FD_Type fp)
  5080.  
  5081.  DESCRIPTION
  5082.   The `_fileno' function returns the underlying integer
  5083.   descriptor for a specified stdio File_Type or
  5084.   FD_Type object.  Upon failure it returns -1 and sets
  5085.   `errno' accordingly.
  5086.  
  5087.  SEE ALSO
  5088.   fileno, fopen, open, fclose, close, dup_fd
  5089.  
  5090. --------------------------------------------------------------
  5091.  
  5092. fileno
  5093.  
  5094.  SYNOPSIS
  5095.   Convert a stdio File_Type object to a FD_Type descriptor
  5096.  
  5097.  USAGE
  5098.   FD_Type fileno (File_Type fp)
  5099.  
  5100.  DESCRIPTION
  5101.   The `fileno' function returns the FD_Type descriptor
  5102.   associated with the stdio File_Type file pointer.  Upon failure,
  5103.   NULL is returned.
  5104.  
  5105.  NOTES
  5106.   Closing the resulting file descriptor will have no effect.
  5107.  
  5108.  SEE ALSO
  5109.   fopen, open, fclose, close, dup_fd, _fileno
  5110.  
  5111. --------------------------------------------------------------
  5112.  
  5113. isatty
  5114.  
  5115.  SYNOPSIS
  5116.   Determine if an open file descriptor refers to a terminal
  5117.  
  5118.  USAGE
  5119.   Int_Type isatty (FD_Type or File_Type fd)
  5120.  
  5121.  DESCRIPTION
  5122.   This function returns 1 if the file descriptor `fd' refers to a
  5123.   terminal; otherwise it returns 0.  The object `fd' may either
  5124.   be a File_Type stdio descriptor or a lower-level FD_Type
  5125.   object.
  5126.  
  5127.  SEE ALSO
  5128.   fopen, fclose, fileno
  5129.  
  5130. --------------------------------------------------------------
  5131.  
  5132. lseek
  5133.  
  5134.  SYNOPSIS
  5135.   Reposition a file descriptor's file pointer
  5136.  
  5137.  USAGE
  5138.   Long_Type lseek (FD_Type fd, LLong_Type ofs, int mode)
  5139.    The `lseek' function repositions the file pointer associated
  5140.    with the open file descriptor `fd' to the offset `ofs'
  5141.    according to the mode parameter.  Specifically, `mode' must be
  5142.    one of the values:
  5143.  
  5144.      SEEK_SET   Set the offset to ofs from the beginning of the file
  5145.      SEEK_CUR   Add ofs to the current offset
  5146.      SEEK_END   Add ofs to the current file size
  5147.  
  5148.    Upon error, `lseek' returns -1 and sets `errno'.  If
  5149.    successful, it returns the new filepointer offset.
  5150.  
  5151.  NOTES
  5152.    Not all file descriptors are capable of supporting the seek
  5153.    operation, e.g., a descriptor associated with a pipe.
  5154.  
  5155.    By using SEEK_END with a positive value of the `ofs'
  5156.    parameter, it is possible to position the file pointer beyond the
  5157.    current size of the file.
  5158.  
  5159.  SEE ALSO
  5160.   fseek, ftell, open, close
  5161.  
  5162. --------------------------------------------------------------
  5163.  
  5164. open
  5165.  
  5166.  SYNOPSIS
  5167.   Open a file
  5168.  
  5169.  USAGE
  5170.   FD_Type open (String_Type filename, Int_Type flags [,Int_Type mode])
  5171.  
  5172.  DESCRIPTION
  5173.   The `open' function attempts to open a file specified by the
  5174.   `filename' parameter according to the `flags' parameter,
  5175.   which must be one of the following values:
  5176.  
  5177.      O_RDONLY   (read-only)
  5178.      O_WRONLY   (write-only)
  5179.      O_RDWR     (read/write)
  5180.  
  5181.   In addition, `flags' may also be bitwise-or'd with any of the
  5182.   following:
  5183.  
  5184.      O_BINARY   (open the file in binary mode)
  5185.      O_TEXT     (open the file in text mode)
  5186.      O_CREAT    (create the file if it does not exist)
  5187.      O_EXCL     (fail if the file already exists)
  5188.      O_NOCTTY   (do not make the device the controlling terminal)
  5189.      O_TRUNC    (truncate the file if it exists)
  5190.      O_APPEND   (open the file in append mode)
  5191.      O_NONBLOCK (open the file in non-blocking mode)
  5192.  
  5193.    Some of these flags make sense only when combined with other flags.
  5194.    For example, if O_EXCL is used, then O_CREAT must also be
  5195.    specified, otherwise unpredictable behavior may result.
  5196.  
  5197.    If O_CREAT is used for the `flags' parameter then the
  5198.    `mode' parameter must be present. `mode' specifies the
  5199.    permissions to use if a new file is created. The actual file
  5200.    permissions will be affected by the process's `umask' via
  5201.    `mode&~umask'.  The `mode' parameter's value is
  5202.    constructed via bitwise-or of the following values:
  5203.  
  5204.      S_IRWXU    (Owner has read/write/execute permission)
  5205.      S_IRUSR    (Owner has read permission)
  5206.      S_IWUSR    (Owner has write permission)
  5207.      S_IXUSR    (Owner has execute permission)
  5208.      S_IRWXG    (Group has read/write/execute permission)
  5209.      S_IRGRP    (Group has read permission)
  5210.      S_IWGRP    (Group has write permission)
  5211.      S_IXGRP    (Group has execute permission)
  5212.      S_IRWXO    (Others have read/write/execute permission)
  5213.      S_IROTH    (Others have read permission)
  5214.      S_IWOTH    (Others have write permission)
  5215.      S_IXOTH    (Others have execute permission)
  5216.  
  5217.    Upon success `open' returns a file descriptor object
  5218.    (FD_Type), otherwise NULL is returned and `errno'
  5219.    is set.
  5220.  
  5221.  NOTES
  5222.    If you are not familiar with the `open' system call, then it
  5223.    is recommended that you use `fopen' instead and use the higher
  5224.    level stdio interface.
  5225.  
  5226.  SEE ALSO
  5227.   fopen, close, read, write, stat_file
  5228.  
  5229. --------------------------------------------------------------
  5230.  
  5231. read
  5232.  
  5233.  SYNOPSIS
  5234.   Read from an open file descriptor
  5235.  
  5236.  USAGE
  5237.   UInt_Type read (FD_Type fd, Ref_Type buf, UInt_Type num)
  5238.  
  5239.  DESCRIPTION
  5240.   The `read' function attempts to read at most `num' bytes
  5241.   into the variable indicated by `buf' from the open file
  5242.   descriptor `fd'.  It returns the number of bytes read, or -1
  5243.   upon failure and sets `errno'.  The number of bytes
  5244.   read may be less than `num', and will be zero if an attempt is
  5245.   made to read past the end of the file.
  5246.  
  5247.  NOTES
  5248.   `read' is a low-level function and may return -1 for a variety
  5249.   of reasons.  For example, if non-blocking I/O has been specified for
  5250.   the open file descriptor and no data is available for reading then
  5251.   the function will return -1 and set `errno' to EAGAIN.
  5252.  
  5253.  SEE ALSO
  5254.   fread, open, close, write
  5255.  
  5256. --------------------------------------------------------------
  5257.  
  5258. write
  5259.  
  5260.  SYNOPSIS
  5261.   Write to an open file descriptor
  5262.  
  5263.  USAGE
  5264.   UInt_Type write (FD_Type fd, BString_Type buf)
  5265.  
  5266.  DESCRIPTION
  5267.    The `write' function attempts to write the bytes specified by
  5268.    the `buf' parameter to the open file descriptor `fd'.  It
  5269.    returns the number of bytes successfully written, or -1 and sets
  5270.    `errno' upon failure.  The number of bytes written may be less
  5271.    than `length(buf)'.
  5272.  
  5273.  SEE ALSO
  5274.   read, fwrite, open, close
  5275.  
  5276. --------------------------------------------------------------
  5277.  
  5278. getegid
  5279.  
  5280.  SYNOPSIS
  5281.   Get the effective group id of the current process
  5282.  
  5283.  USAGE
  5284.   Int_Type getegid ()
  5285.  
  5286.  DESCRIPTION
  5287.   The `getegid' function returns the effective group ID of the
  5288.   current process.
  5289.  
  5290.  NOTES
  5291.   This function is not supported by all systems.
  5292.  
  5293.  SEE ALSO
  5294.   getgid, geteuid, setgid
  5295.  
  5296. --------------------------------------------------------------
  5297.  
  5298. geteuid
  5299.  
  5300.  SYNOPSIS
  5301.   Get the effective user-id of the current process
  5302.  
  5303.  USAGE
  5304.   Int_Type geteuid ()
  5305.  
  5306.  DESCRIPTION
  5307.   The `geteuid' function returns the effective user-id of the
  5308.   current process.
  5309.  
  5310.  NOTES
  5311.   This function is not supported by all systems.
  5312.  
  5313.  SEE ALSO
  5314.   getuid, setuid, setgid
  5315.  
  5316. --------------------------------------------------------------
  5317.  
  5318. getgid
  5319.  
  5320.  SYNOPSIS
  5321.   Get the group id of the current process
  5322.  
  5323.  USAGE
  5324.   Integer_Type getgid ()
  5325.  
  5326.  DESCRIPTION
  5327.   The `getgid' function returns the real group id of the current
  5328.   process.
  5329.  
  5330.  NOTES
  5331.   This function is not supported by all systems.
  5332.  
  5333.  SEE ALSO
  5334.   getpid, getppid
  5335.  
  5336. --------------------------------------------------------------
  5337.  
  5338. getpid
  5339.  
  5340.  SYNOPSIS
  5341.   Get the current process id
  5342.  
  5343.  USAGE
  5344.   Integer_Type getpid ()
  5345.  
  5346.  DESCRIPTION
  5347.   The `getpid' function returns the current process identification
  5348.   number.
  5349.  
  5350.  SEE ALSO
  5351.   getppid, getgid
  5352.  
  5353. --------------------------------------------------------------
  5354.  
  5355. getppid
  5356.  
  5357.  SYNOPSIS
  5358.   Get the parent process id
  5359.  
  5360.  USAGE
  5361.   Integer_Type getppid ()
  5362.  
  5363.  DESCRIPTION
  5364.   The `getpid' function returns the process identification
  5365.   number of the parent process.
  5366.  
  5367.  NOTES
  5368.   This function is not supported by all systems.
  5369.  
  5370.  SEE ALSO
  5371.   getpid, getgid
  5372.  
  5373. --------------------------------------------------------------
  5374.  
  5375. getpriority
  5376.  
  5377.  SYNOPSIS
  5378.   Get a process's scheduling priority
  5379.  
  5380.  USAGE
  5381.   result = getpriority (which, who)
  5382.  
  5383.  DESCRIPTION
  5384.  The `setpriority' function may be used to obtain the kernel's
  5385.  scheduling priority for a process, process group, or a user depending
  5386.  upon the values of the `which' and `who' parameters.
  5387.  Specifically, if the value of `which' is `PRIO_PROCESS',
  5388.  then the value of `who' specifies the process id of the affected
  5389.  process. If `which' is `PRIO_PGRP', then `who'
  5390.  specifies a process group id.  If `which' is `PRIO_USER',
  5391.  then the value of `who' is interpreted as a user id.  For the
  5392.  latter two cases, where `which' refers to a set of processes,
  5393.  the value returned corresponds to the highest priority of a process
  5394.  in the set.  A value of 0 may be used for who to denote the process
  5395.  id, process group id, or real user ID of the current process.
  5396.  
  5397.  Upon success, the function returns the specified priority value.  If
  5398.  an error occurs, the function will return NULL with `errno' set
  5399.  accordingly.
  5400.  
  5401.  NOTES
  5402.  
  5403.  SEE ALSO
  5404.   setpriority, getpid, getppid
  5405.  
  5406. --------------------------------------------------------------
  5407.  
  5408. getuid
  5409.  
  5410.  SYNOPSIS
  5411.   Get the user-id of the current process
  5412.  
  5413.  USAGE
  5414.   Int_Type getuid ()
  5415.  
  5416.  DESCRIPTION
  5417.   The `getuid' function returns the user-id of the current
  5418.   process.
  5419.  
  5420.  NOTES
  5421.   This function is not supported by all systems.
  5422.  
  5423.  SEE ALSO
  5424.   getuid, getegid
  5425.  
  5426. --------------------------------------------------------------
  5427.  
  5428. kill
  5429.  
  5430.  SYNOPSIS
  5431.   Send a signal to a process
  5432.  
  5433.  USAGE
  5434.   Integer_Type kill (Integer_Type pid, Integer_Type sig)
  5435.  
  5436.  DESCRIPTION
  5437.   This function may be used to send a signal given by the integer `sig'
  5438.   to the process specified by `pid'.  The function returns zero upon
  5439.   success or `-1' upon failure setting `errno' accordingly.
  5440.  
  5441.  EXAMPLE
  5442.   The `kill' function may be used to determine whether or not
  5443.   a specific process exists:
  5444.  
  5445.     define process_exists (pid)
  5446.     {
  5447.        if (-1 == kill (pid, 0))
  5448.          return 0;     % Process does not exist
  5449.        return 1;
  5450.     }
  5451.  
  5452.  
  5453.  NOTES
  5454.   This function is not supported by all systems.
  5455.  
  5456.  SEE ALSO
  5457.   getpid
  5458.  
  5459. --------------------------------------------------------------
  5460.  
  5461. mkfifo
  5462.  
  5463.  SYNOPSIS
  5464.   Create a named pipe
  5465.  
  5466.  USAGE
  5467.   Int_Type mkfifo (String_Type name, Int_Type mode)
  5468.  
  5469.  DESCRIPTION
  5470.   The `mkfifo' attempts to create a named pipe with the specified
  5471.   name and mode (modified by the process's umask).  The function
  5472.   returns 0 upon success, or -1 and sets `errno' upon failure.
  5473.  
  5474.  NOTES
  5475.   Not all systems support the `mkfifo' function and even on
  5476.   systems that do implement the `mkfifo' system call, the
  5477.   underlying file system may not support the concept of a named pipe,
  5478.   e.g, an NFS filesystem.
  5479.  
  5480.  SEE ALSO
  5481.   stat_file
  5482.  
  5483. --------------------------------------------------------------
  5484.  
  5485. setgid
  5486.  
  5487.  SYNOPSIS
  5488.   Set the group-id of the current process
  5489.  
  5490.  USAGE
  5491.   Int_Type setgid (Int_Type gid)
  5492.  
  5493.  DESCRIPTION
  5494.   The `setgid' function sets the effective group-id of the current
  5495.   process.  It returns zero upon success, or -1 upon error and sets
  5496.   `errno' appropriately.
  5497.  
  5498.  NOTES
  5499.   This function is not supported by all systems.
  5500.  
  5501.  SEE ALSO
  5502.   getgid, setuid
  5503.  
  5504. --------------------------------------------------------------
  5505.  
  5506. setpgid
  5507.  
  5508.  SYNOPSIS
  5509.   Set the process group-id
  5510.  
  5511.  USAGE
  5512.   Int_Type setpgid (Int_Type pid, Int_Type gid)
  5513.  
  5514.  DESCRIPTION
  5515.   The `setpgid' function sets the group-id `gid' of the
  5516.   process whose process-id is `pid'.  If `pid' is 0, then the
  5517.   current process-id will be used.  If `pgid' is 0, then the pid
  5518.   of the affected process will be used.
  5519.  
  5520.   If successful 0 will be returned, otherwise the function will
  5521.   return -1 and set `errno' accordingly.
  5522.  
  5523.  NOTES
  5524.   This function is not supported by all systems.
  5525.  
  5526.  SEE ALSO
  5527.   setgid, setuid
  5528.  
  5529. --------------------------------------------------------------
  5530.  
  5531. setpriority
  5532.  
  5533.  SYNOPSIS
  5534.   Set the scheduling priority for a process
  5535.  
  5536.  USAGE
  5537.   Int_Type setpriority (which, who, prio)
  5538.  
  5539.  DESCRIPTION
  5540.  The `setpriority' function may be used to set the kernel's
  5541.  scheduling priority for a process, process group, or a user depending
  5542.  upon the values of the `which' and `who' parameters.
  5543.  Specifically, if the value of `which' is `PRIO_PROCESS', then the
  5544.  value of `who' specifies the process id of the affected process.
  5545.  If `which' is `PRIO_PGRP', then `who' specifies a process
  5546.  group id.  If `which' is `PRIO_USER',  then the value of
  5547.  `who' is interpreted as a user id.  A value of 0 may be used for
  5548.  who to denote the process id, process group id, or real user ID of
  5549.  the current process.
  5550.  
  5551.  Upon sucess, the `setpriority' function returns 0.  If an error occurs,
  5552.  -1 is returned and errno will be set accordingly.
  5553.  
  5554.  EXAMPLE
  5555.   The `getpriority' and `setpriority' functions may be used
  5556.   to implement a `nice' function for incrementing the priority of
  5557.   the current process as follows:
  5558.  
  5559.    define nice (dp)
  5560.    {
  5561.       variable p = getpriority (PRIO_PROCESS, 0);
  5562.       if (p == NULL)
  5563.         return -1;
  5564.       variable s = setpriority (PRIO_PROCESS, 0, p + dp);
  5565.       if (s == -1)
  5566.         return -1;
  5567.       return getpriority (PRIO_PROCESS, 0);
  5568.    }
  5569.  
  5570.  
  5571.  NOTES
  5572.  Priority values are sometimes called "nice" values.  The actual
  5573.  range of priority values is system dependent but commonly range from
  5574.  -20 to 20, with -20 being the highest scheduling priority, and +20
  5575.  the lowest.
  5576.  
  5577.  SEE ALSO
  5578.   getpriority, getpid
  5579.  
  5580. --------------------------------------------------------------
  5581.  
  5582. setuid
  5583.  
  5584.  SYNOPSIS
  5585.   Set the user-id of the current process
  5586.  
  5587.  USAGE
  5588.   Int_Type setuid (Int_Type id)
  5589.  
  5590.  DESCRIPTION
  5591.   The `setuid' function sets the effective user-id of the current
  5592.   process.  It returns zero upon success, or -1 upon error and sets
  5593.   `errno' appropriately.
  5594.  
  5595.  NOTES
  5596.   This function is not supported by all systems.
  5597.  
  5598.  SEE ALSO
  5599.   setgid, setpgid, getuid, geteuid
  5600.  
  5601. --------------------------------------------------------------
  5602.  
  5603. sleep
  5604.  
  5605.  SYNOPSIS
  5606.   Pause for a specified number of seconds
  5607.  
  5608.  USAGE
  5609.   sleep (Double_Type n)
  5610.  
  5611.  DESCRIPTION
  5612.   The `sleep' function delays the current process for the
  5613.   specified number of seconds.  If it is interrupted by a signal, it
  5614.   will return prematurely.
  5615.  
  5616.  NOTES
  5617.   Not all system support sleeping for a fractional part of a second.
  5618.  
  5619. --------------------------------------------------------------
  5620.  
  5621. system
  5622.  
  5623.  SYNOPSIS
  5624.   Execute a shell command
  5625.  
  5626.  USAGE
  5627.   Integer_Type system (String_Type cmd)
  5628.  
  5629.  DESCRIPTION
  5630.   The `system' function may be used to execute the string
  5631.   expression `cmd' in an inferior shell.  This function is an
  5632.   interface to the C `system' function which returns an
  5633.   implementation-defined result.   On Linux, it returns 127 if the
  5634.   inferior shell could not be invoked, -1 if there was some other
  5635.   error, otherwise it returns the return code for `cmd'.
  5636.  
  5637.  EXAMPLE
  5638.  
  5639.     define dir ()
  5640.     {
  5641.        () = system ("DIR");
  5642.     }
  5643.  
  5644.   displays a directory listing of the current directory under MSDOS or
  5645.   VMS.
  5646.  
  5647.  SEE ALSO
  5648.   system_intr, new_process, popen
  5649.  
  5650. --------------------------------------------------------------
  5651.  
  5652. system_intr
  5653.  
  5654.  SYNOPSIS
  5655.   Execute a shell command
  5656.  
  5657.  USAGE
  5658.   Integer_Type system_intr (String_Type cmd)
  5659.  
  5660.  DESCRIPTION
  5661.  The `system_intr' function performs the same task as the
  5662.  `system' function, except that the `SIGINT' signal will not
  5663.  be ignored by the calling process.  This means that if a S-Lang script
  5664.  calls `system_intr' function, and Ctrl-C is pressed, both the
  5665.  command invoked by the `system_intr' function and the script
  5666.  will be interrupted.  In contrast, if the command were invoked using
  5667.  the `system' function, only the command called by it would be
  5668.  interrupted, but the script would continue executing.
  5669.  
  5670.  SEE ALSO
  5671.   system, new_process, popen
  5672.  
  5673. --------------------------------------------------------------
  5674.  
  5675. umask
  5676.  
  5677.  SYNOPSIS
  5678.   Set the file creation mask
  5679.  
  5680.  USAGE
  5681.   Int_Type umask (Int_Type m)
  5682.  
  5683.  DESCRIPTION
  5684.   The `umask' function sets the file creation mask to the value of
  5685.   `m' and returns the previous mask.
  5686.  
  5687.  SEE ALSO
  5688.   stat_file
  5689.  
  5690. --------------------------------------------------------------
  5691.  
  5692. uname
  5693.  
  5694.  SYNOPSIS
  5695.   Get the system name
  5696.  
  5697.  USAGE
  5698.   Struct_Type uname ()
  5699.  
  5700.  DESCRIPTION
  5701.   The `uname' function returns a structure containing information
  5702.   about the operating system.  The structure contains the following
  5703.   fields:
  5704.  
  5705.        sysname  (Name of the operating system)
  5706.        nodename (Name of the node within the network)
  5707.        release  (Release level of the OS)
  5708.        version  (Current version of the release)
  5709.        machine  (Name of the hardware)
  5710.  
  5711.  
  5712.  NOTES
  5713.   Not all systems support this function.
  5714.  
  5715.  SEE ALSO
  5716.   getenv
  5717.  
  5718. --------------------------------------------------------------
  5719.  
  5720. qualifier
  5721.  
  5722.  SYNOPSIS
  5723.   Get the value of a qualifier
  5724.  
  5725.  USAGE
  5726.   value = qualifier (String_Type name [,default_value])
  5727.  
  5728.  DESCRIPTION
  5729.  This function may be used to get the value of a qualifer.  If the
  5730.  specified qualifier does not exist, `NULL' will be returned,
  5731.  unless a default value has been provided.
  5732.  
  5733.  EXAMPLE
  5734.  
  5735.     define echo (text)
  5736.     {
  5737.        variable fp = qualifier ("out", stdout);
  5738.        () = fputs (text, fp);
  5739.     }
  5740.     echo ("hello");              % writes hello to stdout
  5741.     echo ("hello"; out=stderr);  % writes hello to stderr
  5742.  
  5743.  
  5744.  NOTES
  5745.  Since `NULL' is a valid value for a qualifier, this function is
  5746.  unable to distinguish between a non-existent qualifier and one whose
  5747.  value is `NULL'.  If such a distinction is important, the
  5748.  `qualifier_exists' function can be used.  For example,
  5749.  
  5750.     define echo (text)
  5751.     {
  5752.        variable fp = stdout;
  5753.        if (qualifier_exists ("use_stderr"))
  5754.          fp = stderr;
  5755.        () = fputs (text, fp);
  5756.     }
  5757.     echo ("hello"; use_stderr);  % writes hello to stderr
  5758.  
  5759.  In this case, no value was provided for the `use_stderr'
  5760.  qualifier: it exists but has a value of `NULL'.
  5761.  
  5762.  SEE ALSO
  5763.   qualifier_exists, __qualifiers
  5764.  
  5765. --------------------------------------------------------------
  5766.  
  5767. __qualifiers
  5768.  
  5769.  SYNOPSIS
  5770.   Get the active set of qualifiers
  5771.  
  5772.  USAGE
  5773.   Struct_Type __qualifiers ()
  5774.  
  5775.  DESCRIPTION
  5776.  This function returns the set of qualifiers associated with the
  5777.  current execution context.  If qualifiers are active, then the result
  5778.  is a structure representing the names of the qualifiers and their
  5779.  corresponding values.  Otherwise `NULL' will be returned.
  5780.  
  5781.  One of the main uses of this function is to pass the current set of
  5782.  qualifiers to another another function.  For example, consider a
  5783.  plotting application with a function called called `lineto' that
  5784.  sets the pen-color before drawing the line to the specified point:
  5785.  
  5786.     define lineto (x, y)
  5787.     {
  5788.        % The color may be specified by a qualifier, defaulting to black
  5789.        variable color = qualifier ("color", "black");
  5790.        set_pen_color (color);
  5791.            .
  5792.            .
  5793.     }
  5794.  
  5795.  The `lineto' function permits the color to be specified by a
  5796.  qualifier.  Now consider a function that make use of lineto to draw a
  5797.  line segment between two points:
  5798.  
  5799.     define line_segment (x0, y0, x1, y1)
  5800.     {
  5801.        moveto (x0, y0);
  5802.        lineto (x1, y1 ; color=qualifier("color", "black"));
  5803.     }
  5804.     line_segment (1,1, 10,10; color="blue");
  5805.  
  5806.  Note that in this implementation of `line_segment', the
  5807.  `color' qualifier was explicitely passed to the `lineto'
  5808.  function.  However, this technique does not scale well.  For example, the
  5809.  `lineto' function might also take a qualifer that specifies the
  5810.  line-style, to be used as
  5811.  
  5812.     line_segment (1,1, 10,10; color="blue", linestyle="solid");
  5813.  
  5814.  But the above implementation of `line_segment' does not pass the
  5815.  `linestyle' qualifier.  In such a case, it is preferable to pass
  5816.  all the qualifiers, e.g.,
  5817.  
  5818.     define line_segment (x0, y0, x1, y1)
  5819.     {
  5820.        moveto (x0, y0);
  5821.        lineto (x1, y1 ;; __qualifiers());
  5822.     }
  5823.  
  5824.  Note the use of the double-semi colon in the `lineto'
  5825.  statement.  This tells the parser that the qualifiers are specified
  5826.  by a structure-valued argument and not a set of name-value pairs.
  5827.  
  5828.  SEE ALSO
  5829.   qualifier, qualifier_exists
  5830.  
  5831. --------------------------------------------------------------
  5832.  
  5833. qualifier_exists
  5834.  
  5835.  SYNOPSIS
  5836.   Check for the existence of a qualifier
  5837.  
  5838.  USAGE
  5839.   Int_Type qualifier_exists (String_Type name)
  5840.  
  5841.  DESCRIPTION
  5842.  This function will return 1 if a qualifier of the specified name
  5843.  exists, or 0 otherwise.
  5844.  
  5845.  SEE ALSO
  5846.   qualifier, __qualifiers
  5847.  
  5848. --------------------------------------------------------------
  5849.  
  5850. rline_bolp
  5851.  
  5852.  SYNOPSIS
  5853.   Test of the editing point is at the beginning of the line
  5854.  
  5855.  USAGE
  5856.   Int_Type rline_bolp()
  5857.  
  5858.  DESCRIPTION
  5859.   The `rline_bolp' function returns a non-zero value if the
  5860.   current editing position is at the beginning of the line.
  5861.  
  5862.  NOTES
  5863.  This function is part of the S-Lang readline interface.
  5864.  
  5865.  SEE ALSO
  5866.   rline_eolp, rline_get_point, rline_get_line
  5867.  
  5868. --------------------------------------------------------------
  5869.  
  5870. rline_eolp
  5871.  
  5872.  SYNOPSIS
  5873.   Test of the editing point is at the end of the line
  5874.  
  5875.  USAGE
  5876.   Int_Type rline_eolp()
  5877.  
  5878.  DESCRIPTION
  5879.   The `rline_bolp' function returns a non-zero value if the
  5880.   current editing position is at the end of the line.
  5881.  
  5882.  NOTES
  5883.  This function is part of the S-Lang readline interface.
  5884.  
  5885.  SEE ALSO
  5886.   rline_bolp, rline_get_point, rline_get_line
  5887.  
  5888. --------------------------------------------------------------
  5889.  
  5890. rline_call
  5891.  
  5892.  SYNOPSIS
  5893.   Invoke an internal readline function
  5894.  
  5895.  USAGE
  5896.   rline_call (String_Type func)
  5897.  
  5898.  DESCRIPTION
  5899.  Not all of the readline functions are available directly from the
  5900.  S-Lang interpreter.  For example, the "deleol" function, which
  5901.  deletes through the end of the line may be executed using
  5902.  
  5903.     rline_call("deleol");
  5904.  
  5905.   See the documentation for the `rline_setkey' function for a
  5906.   list of internal functions that may be invoked by `rline_call'.
  5907.  
  5908.  NOTES
  5909.  This function is part of the S-Lang readline interface.
  5910.  
  5911.  SEE ALSO
  5912.   rline_setkey, rline_del, rline_ins
  5913.  
  5914. --------------------------------------------------------------
  5915.  
  5916. rline_del
  5917.  
  5918.  SYNOPSIS
  5919.   Delete a specified number of characters at the current position
  5920.  
  5921.  USAGE
  5922.   rline_del(Int_Type n)
  5923.  
  5924.  DESCRIPTION
  5925.  This function delete a specified number of characters at the current
  5926.  editing position.  If the number `n' is less than zero, then the
  5927.  previous `n' characters will be deleted.  Otherwise, the next
  5928.  `n' characters will be deleted.
  5929.  
  5930.  NOTES
  5931.  This function is part of the S-Lang readline interface.
  5932.  
  5933.  SEE ALSO
  5934.   rline_ins, rline_setkey
  5935.  
  5936. --------------------------------------------------------------
  5937.  
  5938. rline_get_edit_width
  5939.  
  5940.  SYNOPSIS
  5941.   Get the width of the readline edit window
  5942.  
  5943.  USAGE
  5944.   Int_Type rline_get_edit_width ()
  5945.  
  5946.  DESCRIPTION
  5947.   This function returns the width of the edit window.  For `slsh', this
  5948.   number corresponds to the width of the terminal window.
  5949.  
  5950.  NOTES
  5951.  This function is part of the S-Lang readline interface.
  5952.  
  5953.  SEE ALSO
  5954.   rline_ins
  5955.  
  5956. --------------------------------------------------------------
  5957.  
  5958. rline_get_history
  5959.  
  5960.  SYNOPSIS
  5961.   Retrieve the readline history
  5962.  
  5963.  USAGE
  5964.   Array_Type rline_get_history ()
  5965.  
  5966.  DESCRIPTION
  5967.   This function returns the readline edit history as an array of
  5968.   strings.
  5969.  
  5970.  NOTES
  5971.  This function is part of the S-Lang readline interface.
  5972.  
  5973.  SEE ALSO
  5974.   rline_set_line
  5975.  
  5976. --------------------------------------------------------------
  5977.  
  5978. rline_get_line
  5979.  
  5980.  SYNOPSIS
  5981.   Get a copy of the line being edited
  5982.  
  5983.  USAGE
  5984.   String_Type rline_get_line ()
  5985.  
  5986.  DESCRIPTION
  5987.   This function returns the current edit line.
  5988.  
  5989.  NOTES
  5990.  This function is part of the S-Lang readline interface.
  5991.  
  5992.  SEE ALSO
  5993.   rline_set_line, rline_get_history
  5994.  
  5995. --------------------------------------------------------------
  5996.  
  5997. rline_get_point
  5998.  
  5999.  SYNOPSIS
  6000.   Get the current editing position
  6001.  
  6002.  USAGE
  6003.   Int_Type rline_get_point ()
  6004.  
  6005.  DESCRIPTION
  6006.  The `rline_get_point' function returns the byte-offset of the
  6007.  current editing position.
  6008.  
  6009.  NOTES
  6010.  This function is part of the S-Lang readline interface.
  6011.  
  6012.  SEE ALSO
  6013.   rline_set_point
  6014.  
  6015. --------------------------------------------------------------
  6016.  
  6017. rline_getkey
  6018.  
  6019.  SYNOPSIS
  6020.   Obtain the next byte in the readline input stream
  6021.  
  6022.  USAGE
  6023.   Int_Type rline_getkey ()
  6024.   This function returns the next byte in the readline input stream.
  6025.   If no byte is available, the function will wait until one is.
  6026.  
  6027.  DESCRIPTION
  6028.  
  6029.  NOTES
  6030.  This function is part of the S-Lang readline interface.
  6031.  
  6032.  SEE ALSO
  6033.   rline_input_pending, rline_setkey
  6034.  
  6035. --------------------------------------------------------------
  6036.  
  6037. rline_input_pending
  6038.  
  6039.  SYNOPSIS
  6040.   Test to see if readline input is available for reading
  6041.  
  6042.  USAGE
  6043.   Int_Type rline_input_pending (Int_Type tsecs)
  6044.  
  6045.  DESCRIPTION
  6046.   This function returns a non-zero value if readline input is
  6047.   available to be read.  If none is immediately available, it will
  6048.   wait for up to `tsecs' tenths of a second for input before
  6049.   returning.
  6050.  
  6051.  NOTES
  6052.  This function is part of the S-Lang readline interface.
  6053.  
  6054.  SEE ALSO
  6055.   rline_getkey
  6056.  
  6057. --------------------------------------------------------------
  6058.  
  6059. rline_ins
  6060.  
  6061.  SYNOPSIS
  6062.   Insert a string at the current editing point
  6063.  
  6064.  USAGE
  6065.   rline_ins (String_Type text)
  6066.  
  6067.  DESCRIPTION
  6068.   This function inserts the specified string into the line being edited.
  6069.  
  6070.  NOTES
  6071.  This function is part of the S-Lang readline interface.
  6072.  
  6073.  SEE ALSO
  6074.   rline_set_line, rline_del
  6075.  
  6076. --------------------------------------------------------------
  6077.  
  6078. rline_set_history
  6079.  
  6080.  SYNOPSIS
  6081.   Replace the current history list with a new one
  6082.  
  6083.  USAGE
  6084.   rline_set_history (Array_Type lines)
  6085.  
  6086.  DESCRIPTION
  6087.   The `rline_set_history' function replaces the current history
  6088.   by the specified array of strings.
  6089.  
  6090.  NOTES
  6091.  This function is part of the S-Lang readline interface.
  6092.  
  6093.  SEE ALSO
  6094.   rline_get_history
  6095.  
  6096. --------------------------------------------------------------
  6097.  
  6098. rline_set_line
  6099.  
  6100.  SYNOPSIS
  6101.   Replace the current line with a new one
  6102.  
  6103.  USAGE
  6104.   rline_set_line (String_Type line)
  6105.  
  6106.  DESCRIPTION
  6107.   The `rline_set_line' function replaces the line being edited by
  6108.   the specified one.
  6109.  
  6110.  NOTES
  6111.  This function is part of the S-Lang readline interface.
  6112.  
  6113.  SEE ALSO
  6114.   rline_get_line
  6115.  
  6116. --------------------------------------------------------------
  6117.  
  6118. rline_set_point
  6119.  
  6120.  SYNOPSIS
  6121.   Move the current editing position to another
  6122.  
  6123.  USAGE
  6124.   rline_set_point (Int_Type ofs)
  6125.  
  6126.  DESCRIPTION
  6127.  The `rline_set_point' function sets the editing point to the
  6128.  specified byte-offset from the beginning of the line.
  6129.  
  6130.  NOTES
  6131.  This function is part of the S-Lang readline interface.
  6132.  
  6133.  SEE ALSO
  6134.   rline_get_point
  6135.  
  6136. --------------------------------------------------------------
  6137.  
  6138. rline_setkey
  6139.  
  6140.  SYNOPSIS
  6141.   Bind a key in the readline keymap to a function
  6142.  
  6143.  USAGE
  6144.   rline_setkey (func, keyseq)
  6145.  
  6146.  DESCRIPTION
  6147.   The `rline_setkey' function binds the function `func' to
  6148.   the specified key sequence `keyseq'.  The value of `func'
  6149.   may be either a reference to a S-Lang function, or a string giving
  6150.   the name of an internal readline function.
  6151.  
  6152.   Functions that are internal to the readline interface include:
  6153.  
  6154.    bdel             Delete the previous character
  6155.    bol              Move to the beginning of the line
  6156.    complete         The command line completion function
  6157.    del              Delete the character at the current position
  6158.    delbol           Delete to the beginning of the line
  6159.    deleol           Delete through the end of the line
  6160.    down             Goto the next line in the history
  6161.    enter            Return to the caller of the readline function
  6162.    eol              Move to the end of the line
  6163.    kbd_quit         Abort editing of the current line
  6164.    left             Move left one character
  6165.    quoted_insert    Insert the next byte into the line
  6166.    redraw           Redraw the line
  6167.    right            Move right one character
  6168.    self_insert      Insert the byte that invoked the function
  6169.    trim             Remove whitespace about the current position
  6170.    up               Goto the previous line in the history
  6171.  
  6172.  
  6173.  NOTES
  6174.  This function is part of the S-Lang readline interface.
  6175.  
  6176.  SEE ALSO
  6177.   rline_unsetkey
  6178.  
  6179. --------------------------------------------------------------
  6180.  
  6181. rline_unsetkey
  6182.  
  6183.  SYNOPSIS
  6184.   Unset a key binding from the readline keymap
  6185.  
  6186.  USAGE
  6187.   rline_unsetkey (String_Type keyseq)
  6188.  
  6189.  DESCRIPTION
  6190.   The `rline_unsetkey' function unbinds the specified key sequence
  6191.   from the readline keymap.
  6192.  
  6193.  NOTES
  6194.  This function is part of the S-Lang readline interface.
  6195.  
  6196.  SEE ALSO
  6197.   rline_setkey
  6198.  
  6199. --------------------------------------------------------------
  6200.  
  6201. rline_set_list_completions_callback
  6202.  
  6203.  SYNOPSIS
  6204.   Set a callback function to display the list of completions
  6205.  
  6206.  USAGE
  6207.   rline_set_list_completions_callback (Ref_Type func)
  6208.  
  6209.  DESCRIPTION
  6210.   This function sets the S-Lang function that is to be used to display the
  6211.   list of possible completions for current word at the readline prompt.
  6212.   The callback function must be defined to accept a single parameter
  6213.   representing an array of completion strings.
  6214.  
  6215.  EXAMPLE
  6216.   This callback function writes the completions using the message
  6217.   functions:
  6218.  
  6219.      private define display_completions (strings)
  6220.      {
  6221.         variable str;
  6222.         vmessage ("There are %d completions:\n", length(strings));
  6223.         foreach str (strings) vmessage ("%s\n", str);
  6224.      }
  6225.      rline_set_list_completions_callback (&display_completions);
  6226.  
  6227.  
  6228.  NOTES
  6229.  
  6230.  SEE ALSO
  6231.   rline_set_completion_callback
  6232.  
  6233. --------------------------------------------------------------
  6234.  
  6235. rline_set_completion_callback
  6236.  
  6237.  SYNOPSIS
  6238.   Set the function to be used for completion at the readline prompt
  6239.  
  6240.  USAGE
  6241.   rline_set_completion_callback (Ref_Type func)
  6242.  
  6243.  DESCRIPTION
  6244.   This function sets the callback function to be used for completion at the
  6245.   readline prompt.  The callback function must be defined to accept
  6246.   two values, the first being a string containing the text of the line
  6247.   being edited, and an integer giving the position of the byte-offset
  6248.   into the string where completion was requested.
  6249.  
  6250.   The callback function must return two values: an array giving the
  6251.   list of possible completion strings, and an integer giving the byte
  6252.   offset into the string of the start of the text to be completed.
  6253.  
  6254.  EXAMPLE
  6255.   See completion-callback function defined in the `slsh' library file
  6256.   `rline/complete.sl'.
  6257.  
  6258.  NOTES
  6259.  This function is part of the S-Lang readline interface.
  6260.  
  6261.  SEE ALSO
  6262.   rline_set_list_completions_callback
  6263.  
  6264. --------------------------------------------------------------
  6265.  
  6266. alarm
  6267.  
  6268.  SYNOPSIS
  6269.   Schedule an alarm signal
  6270.  
  6271.  USAGE
  6272.   alarm (UInt_Type secs [, Ref_Type secs_remaining])
  6273.  
  6274.  DESCRIPTION
  6275.   The `alarm' function schedules the delivery of a SIGALRM
  6276.   signal in `secs' seconds.  Any previously scheduled alarm will
  6277.   be canceled.  If `secs' is zero, then no new alarm will be
  6278.   scheduled.  If the second argument is present, then it must be a
  6279.   reference to a variable whose value will be set upon return to the
  6280.   number of seconds remaining for a previously scheduled alarm to take
  6281.   place.
  6282.  
  6283.  EXAMPLE
  6284.   This example shows demonstrates how the `alarm' function may be
  6285.   used to read from a file within a specified amount of time:
  6286.  
  6287.     define sigalrm_handler (sig)
  6288.     {
  6289.        throw ReadError, "Read timed out";
  6290.     }
  6291.     define read_or_timeout (secs)
  6292.     {
  6293.        variable line, e;
  6294.        variable fp = fopen ("/dev/tty", "r");
  6295.        signal (SIGALRM, &sigalrm_handler);
  6296.        alarm (secs);
  6297.        try (e)
  6298.          {
  6299.             () = fputs ("Enter some text> ", stdout); () = fflush (stdout);
  6300.             if (-1 == fgets (&line, fp))
  6301.               line = NULL;
  6302.          }
  6303.        catch IOError: { message (e.message); line = NULL; }
  6304.        return line;
  6305.     }
  6306.  
  6307.  
  6308.  NOTES
  6309.   Some operating systems may implement the `sleep' function using
  6310.   `alarm'.  As a result, it is not a good idea to mix calls to
  6311.   `alarm' and `sleep'.
  6312.  
  6313.   The default action for SIGALRM is to terminate the process.
  6314.   Hence, if `alarm' is called it is wise to establish a signal
  6315.   handler for `SIGALRM'.
  6316.  
  6317.  SEE ALSO
  6318.   signal, sleep
  6319.  
  6320. --------------------------------------------------------------
  6321.  
  6322. signal
  6323.  
  6324.  SYNOPSIS
  6325.   Establish a signal handler
  6326.  
  6327.  USAGE
  6328.   signal (Int_Type sig, Ref_Type func [,Ref_Type old_func])
  6329.  
  6330.  DESCRIPTION
  6331.   The `signal' function assigns the signal handler represented by
  6332.   `func' to the signal `sig'.  Here `func' is usually
  6333.   reference to a function that takes an integer argument (the signal)
  6334.   and returns nothing, e.g.,
  6335.  
  6336.     define signal_handler (sig)
  6337.     {
  6338.        return;
  6339.     }
  6340.  
  6341.   Alternatively, `func' may be given by one of the symbolic
  6342.   constants SIG_IGN or SIG_DFL to indicate that the
  6343.   signal is to be ignored or given its default action, respectively.
  6344.  
  6345.   The first parameter, `sig', specifies the signal to be handled.
  6346.   The actual supported values vary with the OS.  Common values on Unix
  6347.   include `SIGHUP', `SIGINT', and `SIGTERM'.
  6348.  
  6349.   If a third argument is present, then it must be a reference to a
  6350.   variable whose value will be set to the value of the previously
  6351.   installed handler.
  6352.  
  6353.  EXAMPLE
  6354.   This example establishes a handler for `SIGTSTP'.
  6355.  
  6356.     static define sig_suspend ();  % forward declaration
  6357.     static define sig_suspend (sig)
  6358.     {
  6359.        message ("SIGTSTP received-- stopping");
  6360.        signal (sig, SIG_DFL);
  6361.        () = kill (getpid(), SIGSTOP);
  6362.        message ("Resuming");
  6363.        signal (sig, &sig_suspend);
  6364.     }
  6365.     signal (SIGTSTP, &sig_suspend);
  6366.  
  6367.  
  6368.  NOTES
  6369.   Currently the signal interface is supported only on systems that
  6370.   implement signals according to the POSIX standard.
  6371.  
  6372.   Once a signal has been received, it will remain blocked until after
  6373.   the signal handler has completed.  This is the reason SIGSTOP
  6374.   was used in the above signal handler instead of SIGTSTP.
  6375.  
  6376.  SEE ALSO
  6377.   alarm, sigsuspend, sigprocmask
  6378.  
  6379. --------------------------------------------------------------
  6380.  
  6381. sigprocmask
  6382.  
  6383.  SYNOPSIS
  6384.   Change the list of currently blocked signals
  6385.  
  6386.  USAGE
  6387.   sigprocmask (Int_Type how, Array_Type mask [,Ref_Type old_mask])
  6388.  
  6389.  DESCRIPTION
  6390.   The `sigprocmask' function may be used to change the list of
  6391.   signals that are currently blocked.  The first parameter indicates
  6392.   how this is accomplished.  Specifically, `how' must be one of
  6393.   the following values: SIG_BLOCK, SIG_UNBLOCK, or
  6394.   SIG_SETMASK.
  6395.  
  6396.   If `how' is SIG_BLOCK, then the set of blocked signals
  6397.   will be the union the current set with the values specified in the
  6398.   `mask' argument.
  6399.  
  6400.   If `how' is SIG_UNBLOCK, then the signals specified by
  6401.   the `mask' parameter will be removed from the currently blocked
  6402.   set.
  6403.  
  6404.   If `how' is SIG_SETMASK, then the set of blocked signals
  6405.   will be set to those given by the `mask'.
  6406.  
  6407.   If a third argument is present, then it must be a reference to a
  6408.   variable whose value will be set to the previous signal mask.
  6409.  
  6410.  SEE ALSO
  6411.   signal, sigsuspend, alarm
  6412.  
  6413. --------------------------------------------------------------
  6414.  
  6415. sigsuspend
  6416.  
  6417.  SYNOPSIS
  6418.   Suspend the process until a signal is delivered
  6419.  
  6420.  USAGE
  6421.   sigsuspend ([Array_Type signal_mask])
  6422.  
  6423.  DESCRIPTION
  6424.   The
  6425. sigsuspend
  6426.  function suspends the current process
  6427.   until a signal is received.  An optional array argument may be
  6428.   passed to the function to specify a list of signals that should be
  6429.   temporarily blocked while waiting for a signal.
  6430.  
  6431.  EXAMPLE
  6432.   The following example pauses the current process for 10 seconds
  6433.   while blocking the SIGHUP and SIGINT signals.
  6434.  
  6435.      static variable Tripped;
  6436.      define sigalrm_handler (sig)
  6437.      {
  6438.         Tripped = 1;
  6439.      }
  6440.      signal (SIGALRM, &sigalrm_handler);
  6441.      Tripped = 0;
  6442.      alarm (10);
  6443.      while (Tripped == 0) sigsuspend ([SIGHUP, SIGINT]);
  6444.  
  6445.   Note that in this example the call to `sigsuspend' was wrapped in
  6446.   a while-loop.  This was necessary because there is no guarantee that
  6447.   another signal would not cause `sigsuspend' to return.
  6448.  
  6449.  SEE ALSO
  6450.   signal, alarm, sigprocmask
  6451.  
  6452. --------------------------------------------------------------
  6453.  
  6454. dup
  6455.  
  6456.  SYNOPSIS
  6457.   Duplicate the value at the top of the stack
  6458.  
  6459.  USAGE
  6460.   dup ()
  6461.  
  6462.  DESCRIPTION
  6463.   This function returns an exact duplicate of the object on top of the
  6464.   stack.  For some objects such as arrays or structures, it creates a
  6465.   new reference to the object.  However, for simple scalar S-Lang types such
  6466.   as strings, integers, and doubles, it creates a new copy of the
  6467.   object.
  6468.  
  6469.  SEE ALSO
  6470.   pop, typeof
  6471.  
  6472. --------------------------------------------------------------
  6473.  
  6474. exch
  6475.  
  6476.  SYNOPSIS
  6477.   Exchange two items on the stack
  6478.  
  6479.  USAGE
  6480.   exch ()
  6481.  
  6482.  DESCRIPTION
  6483.   The `exch' swaps the two top items on the stack.
  6484.  
  6485.  SEE ALSO
  6486.   pop, _stk_reverse, _stk_roll
  6487.  
  6488. --------------------------------------------------------------
  6489.  
  6490. pop
  6491.  
  6492.  SYNOPSIS
  6493.   Discard an item from the stack
  6494.  
  6495.  USAGE
  6496.   pop ()
  6497.  
  6498.  DESCRIPTION
  6499.   The `pop' function removes the top item from the stack.
  6500.  
  6501.  SEE ALSO
  6502.   _pop_n, __pop_args
  6503.  
  6504. --------------------------------------------------------------
  6505.  
  6506. __pop_args
  6507.  
  6508.  SYNOPSIS
  6509.   Remove n function arguments from the stack
  6510.  
  6511.  USAGE
  6512.   args = __pop_args(Integer_Type n)
  6513.  
  6514.  DESCRIPTION
  6515.   This function, together with the companion function
  6516.   `__push_args', is useful for creating a function that takes a
  6517.   variable number of arguments, as well as passing the arguments of
  6518.   one function to another function.
  6519.  
  6520.   `__pop_args' removes the specified number of values from the
  6521.   stack and returns them as an array of structures of the corresponding
  6522.   length.  Each structure in the array consists of a single
  6523.   field called `value', which represents the value of the
  6524.   argument.
  6525.  
  6526.  EXAMPLE
  6527.   Consider the following function.  It prints all its arguments to
  6528.   `stdout' separated by spaces:
  6529.  
  6530.     define print_args ()
  6531.     {
  6532.        variable i;
  6533.        variable args = __pop_args (_NARGS);
  6534.  
  6535.        for (i = 0; i < _NARGS; i++)
  6536.          {
  6537.             () = fputs (string (args[i].value), stdout);
  6538.             () = fputs (" ", stdout);
  6539.          }
  6540.        () = fputs ("\n", stdout);
  6541.        () = fflush (stdout);
  6542.     }
  6543.  
  6544.   Now consider the problem of defining a function called `ones'
  6545.   that returns a multi-dimensional array with all the elements set to
  6546.   1.  For example, `ones(10)' should return a 1-d array of 10
  6547.   ones, whereas `ones(10,20)' should return a 10x20 array.
  6548.  
  6549.     define ones ()
  6550.     {
  6551.       !if (_NARGS) return 1;
  6552.       variable a;
  6553.  
  6554.       a = __pop_args (_NARGS);
  6555.       return @Array_Type (Integer_Type, [__push_args (a)]) + 1;
  6556.     }
  6557.  
  6558.   Here, `__push_args' was used to push the arguments passed to
  6559.   the `ones' function onto the stack to be used when dereferencing
  6560.   Array_Type.
  6561.  
  6562.  NOTES
  6563.   This function has been superseded by the `__pop_list' function,
  6564.   which returns the objects as a list instead of an array of structures.
  6565.  
  6566.  SEE ALSO
  6567.   __push_args, __pop_list, __push_list, typeof, _pop_n
  6568.  
  6569. --------------------------------------------------------------
  6570.  
  6571. __pop_list
  6572.  
  6573.  SYNOPSIS
  6574.   Convert items on the stack to a List_Type
  6575.  
  6576.  USAGE
  6577.   List_Type = __pop_list (Int_Type n)
  6578.  
  6579.  DESCRIPTION
  6580.  This function removes a specified number of items from the stack and
  6581.  converts returns them in the form of a list.
  6582.  
  6583.  EXAMPLE
  6584.  
  6585.   define print_args ()
  6586.   {
  6587.      variable list = __pop_list (_NARGS);
  6588.      variable i;
  6589.      _for i (0, length(list)-1, 1)
  6590.         {
  6591.            vmessage ("arg[%d]: %S", i, list[i]);
  6592.         }
  6593.   }
  6594.  
  6595.  
  6596.  NOTES
  6597.  
  6598.  SEE ALSO
  6599.   __push_list
  6600.  
  6601. --------------------------------------------------------------
  6602.  
  6603. _pop_n
  6604.  
  6605.  SYNOPSIS
  6606.   Remove objects from the stack
  6607.  
  6608.  USAGE
  6609.   _pop_n (Integer_Type n);
  6610.  
  6611.  DESCRIPTION
  6612.   The `_pop_n' function removes the specified number of objects
  6613.   from the top of the stack.
  6614.  
  6615.  SEE ALSO
  6616.   _stkdepth, pop
  6617.  
  6618. --------------------------------------------------------------
  6619.  
  6620. _print_stack
  6621.  
  6622.  SYNOPSIS
  6623.   Print the values on the stack.
  6624.  
  6625.  USAGE
  6626.   _print_stack ()
  6627.  
  6628.  DESCRIPTION
  6629.   This function dumps out what is currently on the S-Lang stack.  It does not
  6630.   alter the stack and it is usually used for debugging purposes.
  6631.  
  6632.  SEE ALSO
  6633.   _stkdepth, string, message
  6634.  
  6635. --------------------------------------------------------------
  6636.  
  6637. __push_args
  6638.  
  6639.  SYNOPSIS
  6640.   Move n function arguments onto the stack
  6641.  
  6642.  USAGE
  6643.   __push_args (Struct_Type args);
  6644.  
  6645.  DESCRIPTION
  6646.   This function together with the companion function `__pop_args'
  6647.   is useful for the creation of functions that take a variable number
  6648.   of arguments.  See the description of `__pop_args' for more
  6649.   information.
  6650.  
  6651.  NOTES
  6652.   This function has been superseded by the `__push_list' function.
  6653.  
  6654.  SEE ALSO
  6655.   __pop_args, __push_list, __pop_list, typeof, _pop_n
  6656.  
  6657. --------------------------------------------------------------
  6658.  
  6659. __push_list
  6660.  
  6661.  SYNOPSIS
  6662.   Push the elements of a list to the stack
  6663.  
  6664.  USAGE
  6665.   __push_list (List_Type list)
  6666.  
  6667.  DESCRIPTION
  6668.  This function pushes the elements of a list to the stack.
  6669.  
  6670.  EXAMPLE
  6671.  
  6672.  private define list_to_array (list)
  6673.  {
  6674.     return [__push_list (list)];
  6675.  }
  6676.  
  6677.  
  6678.  SEE ALSO
  6679.   __pop_list
  6680.  
  6681. --------------------------------------------------------------
  6682.  
  6683. _stkdepth
  6684.  
  6685.  USAGE
  6686.   Get the number of objects currently on the stack
  6687.  
  6688.  SYNOPSIS
  6689.   Integer_Type _stkdepth ()
  6690.  
  6691.  DESCRIPTION
  6692.   The `_stkdepth' function returns number of items on the stack.
  6693.  
  6694.  SEE ALSO
  6695.   _print_stack, _stk_reverse, _stk_roll
  6696.  
  6697. --------------------------------------------------------------
  6698.  
  6699. _stk_reverse
  6700.  
  6701.  SYNOPSIS
  6702.   Reverse the order of the objects on the stack
  6703.  
  6704.  USAGE
  6705.   _stk_reverse (Integer_Type n)
  6706.  
  6707.  DESCRIPTION
  6708.    The `_stk_reverse' function reverses the order of the top
  6709.    `n' items on the stack.
  6710.  
  6711.  SEE ALSO
  6712.   _stkdepth, _stk_roll
  6713.  
  6714. --------------------------------------------------------------
  6715.  
  6716. _stk_roll
  6717.  
  6718.  SYNOPSIS
  6719.   Roll items on the stack
  6720.  
  6721.  USAGE
  6722.   _stk_roll (Integer_Type n)
  6723.  
  6724.  DESCRIPTION
  6725.   This function may be used to alter the arrangement of objects on the
  6726.   stack.  Specifically, if the integer `n' is positive, the top
  6727.   `n' items on the stack are rotated up.  If
  6728.   `n' is negative, the top `abs(n)' items on the stack are
  6729.   rotated down.
  6730.  
  6731.  EXAMPLE
  6732.   If the stack looks like:
  6733.  
  6734.     item-0
  6735.     item-1
  6736.     item-2
  6737.     item-3
  6738.  
  6739.   where `item-0' is at the top of the stack, then
  6740.   `_stk_roll(-3)' will change the stack to:
  6741.  
  6742.     item-2
  6743.     item-0
  6744.     item-1
  6745.     item-3
  6746.  
  6747.  
  6748.  NOTES
  6749.   This function only has an effect if `abs(n) > 1'.
  6750.  
  6751.  SEE ALSO
  6752.   _stkdepth, _stk_reverse, _pop_n, _print_stack
  6753.  
  6754. --------------------------------------------------------------
  6755.  
  6756. clearerr
  6757.  
  6758.  SYNOPSIS
  6759.   Clear the error of a file stream
  6760.  
  6761.  USAGE
  6762.   clearerr (File_Type fp
  6763.  
  6764.  DESCRIPTION
  6765.   The `clearerr' function clears the error and end-of-file flags
  6766.   associated with the open file stream `fp'.
  6767.  
  6768.  SEE ALSO
  6769.   ferror, feof, fopen
  6770.  
  6771. --------------------------------------------------------------
  6772.  
  6773. fclose
  6774.  
  6775.  SYNOPSIS
  6776.   Close a file
  6777.  
  6778.  USAGE
  6779.   Integer_Type fclose (File_Type fp)
  6780.  
  6781.  DESCRIPTION
  6782.   The `fclose' function may be used to close an open file pointer
  6783.   `fp'.  Upon success it returns zero, and upon failure it sets
  6784.   `errno' and returns `-1'.  Failure usually indicates a that
  6785.   the file system is full or that `fp' does not refer to an open file.
  6786.  
  6787.  NOTES
  6788.   Many C programmers call `fclose' without checking the return
  6789.   value.  The S-Lang language requires the programmer to explicitly
  6790.   handle any value returned by a function.  The simplest way to
  6791.   handle the return value from `fclose' is to call it via:
  6792.  
  6793.      () = fclose (fp);
  6794.  
  6795.  
  6796.  SEE ALSO
  6797.   fopen, fgets, fflush, pclose, errno
  6798.  
  6799. --------------------------------------------------------------
  6800.  
  6801. fdopen
  6802.  
  6803.  SYNOPSIS
  6804.   Convert a FD_Type file descriptor to a stdio File_Type object
  6805.  
  6806.  USAGE
  6807.   File_Type fdopen (FD_Type, String_Type mode)
  6808.  
  6809.  DESCRIPTION
  6810.    The `fdopen' function creates and returns a stdio
  6811.    File_Type object from the open FD_Type
  6812.    descriptor `fd'.  The `mode' parameter corresponds to the
  6813.    `mode' parameter of the `fopen' function and must be
  6814.    consistent with the mode of the descriptor `fd'.  The function
  6815.    returns NULL upon failure and sets `errno'.
  6816.  
  6817.  NOTES
  6818.    Since the stdio File_Type object created by this function
  6819.    is derived from the FD_Type descriptor, the FD_Type
  6820.    is regarded as more fundamental than the File_Type object.
  6821.    This means that the descriptor must be in scope while the
  6822.    File_Type object is used.  In particular, if the descriptor
  6823.    goes out of scope, the descriptor will get closed causing I/O to the
  6824.    File_Type object to fail, e.g.,
  6825.  
  6826.      fd = open ("/path/to/file", O_RDONLY);
  6827.      fp = fdopen (fd);
  6828.      fd = 0;     % This will cause the FD_Type descriptor to go out of
  6829.                  % scope.  Any I/O on fp will now fail.
  6830.  
  6831.  
  6832.    Calling the `fclose' function on the File_Type object
  6833.    will cause the underlying descriptor to close.
  6834.  
  6835.    Any stdio File_Type object created by the `fdopen'
  6836.    function will remain associated with the FD_Type descriptor,
  6837.    unless the object is explicitly removed via `fclose'.  This
  6838.    means that code such as
  6839.  
  6840.       fd = open (...);
  6841.       loop (50)
  6842.         {
  6843.            fp = fdopen (fd, ...);
  6844.               .
  6845.               .
  6846.         }
  6847.  
  6848.    will result in 50 File_Type objects attached to `fd'
  6849.    after the loop has terminated.
  6850.  
  6851.  SEE ALSO
  6852.   fileno, fopen, open, close, fclose, dup_fd
  6853.  
  6854. --------------------------------------------------------------
  6855.  
  6856. feof
  6857.  
  6858.  SYNOPSIS
  6859.   Get the end-of-file status
  6860.  
  6861.  USAGE
  6862.   Integer_Type feof (File_Type fp)
  6863.  
  6864.  DESCRIPTION
  6865.   This function may be used to determine the state of the end-of-file
  6866.   indicator of the open file descriptor `fp'.  It returns zero
  6867.   if the indicator is not set, or non-zero if it is.  The end-of-file
  6868.   indicator may be cleared by the `clearerr' function.
  6869.  
  6870.  SEE ALSO
  6871.   ferror, clearerr, fopen
  6872.  
  6873. --------------------------------------------------------------
  6874.  
  6875. ferror
  6876.  
  6877.  SYNOPSIS
  6878.   Determine the error status of an open file descriptor
  6879.  
  6880.  USAGE
  6881.   Integer_Type ferror (File_Type fp)
  6882.  
  6883.  DESCRIPTION
  6884.   This function may be used to determine the state of the error
  6885.   indicator of the open file descriptor `fp'.  It returns zero
  6886.   if the indicator is not set, or non-zero if it is.  The error
  6887.   indicator may be cleared by the `clearerr' function.
  6888.  
  6889.  SEE ALSO
  6890.   feof, clearerr, fopen
  6891.  
  6892. --------------------------------------------------------------
  6893.  
  6894. fflush
  6895.  
  6896.  SYNOPSIS
  6897.   Flush an output stream
  6898.  
  6899.  USAGE
  6900.   Integer_Type fflush (File_Type fp)
  6901.  
  6902.  DESCRIPTION
  6903.   The `fflush' function may be used to update the stdio _output_
  6904.   stream specified by `fp'.  It returns 0 upon success, or
  6905.   -1 upon failure and sets `errno' accordingly.  In
  6906.   particular, this function will fail if `fp' does not represent
  6907.   an open output stream, or if `fp' is associated with a disk file and
  6908.   there is insufficient disk space.
  6909.  
  6910.  EXAMPLE
  6911.   This example illustrates how to use the `fflush' function
  6912.   without regard to the return value:
  6913.  
  6914.     () = fputs ("Enter value> ", stdout);
  6915.     () = fflush (stdout);
  6916.  
  6917.  
  6918.  SEE ALSO
  6919.   fopen, fclose
  6920.  
  6921. --------------------------------------------------------------
  6922.  
  6923. fgets
  6924.  
  6925.  SYNOPSIS
  6926.   Read a line from a file
  6927.  
  6928.  USAGE
  6929.   Integer_Type fgets (SLang_Ref_Type ref, File_Type fp)
  6930.  
  6931.  DESCRIPTION
  6932.   `fgets' reads a line from the open file specified by `fp'
  6933.   and places the characters in the variable whose reference is
  6934.   specified by `ref'.
  6935.   It returns -1 if `fp' is not associated with an open file
  6936.   or an attempt was made to read at the end the file; otherwise, it
  6937.   returns the number of characters read.
  6938.  
  6939.  EXAMPLE
  6940.   The following example returns the lines of a file via a linked list:
  6941.  
  6942.     define read_file (file)
  6943.     {
  6944.        variable buf, fp, root, tail;
  6945.        variable list_type = struct { text, next };
  6946.  
  6947.        root = NULL;
  6948.  
  6949.        fp = fopen(file, "r");
  6950.        if (fp == NULL)
  6951.          error("fopen %s failed." file);
  6952.        while (-1 != fgets (&buf, fp))
  6953.          {
  6954.             if (root == NULL)
  6955.               {
  6956.                  root = @list_type;
  6957.                  tail = root;
  6958.               }
  6959.             else
  6960.               {
  6961.                  tail.next = @list_type;
  6962.                  tail = tail.next;
  6963.               }
  6964.             tail.text = buf;
  6965.             tail.next = NULL;
  6966.          }
  6967.        () = fclose (fp);
  6968.        return root;
  6969.     }
  6970.  
  6971.  
  6972.  SEE ALSO
  6973.   fgetslines, fopen, fclose, fputs, fread, error
  6974.  
  6975. --------------------------------------------------------------
  6976.  
  6977. fgetslines
  6978.  
  6979.  SYNOPSIS
  6980.   Read lines as an array from an open file
  6981.  
  6982.  USAGE
  6983.   String_Type[] fgetslines (File_Type fp [,Int_Type num])
  6984.  
  6985.  DESCRIPTION
  6986.   The `fgetslines' function reads lines a specified number of
  6987.   lines as an array of strings from the file associated with the
  6988.   file pointer `fp'.  If the number of lines to be read is left
  6989.   unspecified, the function will return the rest of the lines in the
  6990.   file.  If the file is empty, an empty string array will be returned.
  6991.   The function returns NULL upon error.
  6992.  
  6993.  EXAMPLE
  6994.   The following function returns the number of lines in a file:
  6995.  
  6996.     define count_lines_in_file (file)
  6997.     {
  6998.        variable fp, lines;
  6999.  
  7000.        fp = fopen (file, "r");
  7001.        if (fp == NULL)
  7002.          return -1;
  7003.  
  7004.        lines = fgetslines (fp);
  7005.        if (lines == NULL)
  7006.          return -1;
  7007.  
  7008.        return length (lines);
  7009.     }
  7010.  
  7011.   Note that the file was implicitly closed when the variable `fp'
  7012.   goes out of scope (in the case, when the function returns).
  7013.  
  7014.  SEE ALSO
  7015.   fgets, fread, fopen, fputslines
  7016.  
  7017. --------------------------------------------------------------
  7018.  
  7019. fopen
  7020.  
  7021.  SYNOPSIS
  7022.   Open a file
  7023.  
  7024.  USAGE
  7025.   File_Type fopen (String_Type f, String_Type m)
  7026.  
  7027.  DESCRIPTION
  7028.   The `fopen' function opens a file `f' according to the mode
  7029.   string `m'.  Allowed values for `m' are:
  7030.  
  7031.      "r"    Read only
  7032.      "w"    Write only
  7033.      "a"    Append
  7034.      "r+"   Reading and writing at the beginning of the file.
  7035.      "w+"   Reading and writing.  The file is created if it does not
  7036.               exist; otherwise, it is truncated.
  7037.      "a+"   Reading and writing at the end of the file.  The file is created
  7038.               if it does not already exist.
  7039.  
  7040.   In addition, the mode string can also include the letter `'b''
  7041.   as the last character to indicate that the file is to be opened in
  7042.   binary mode.
  7043.  
  7044.   Upon success, `fopen' returns a File_Type object which is
  7045.   meant to be used by other operations that require an open file
  7046.   pointer.  Upon failure, the function returns NULL.
  7047.  
  7048.  EXAMPLE
  7049.   The following function opens a file in append mode and writes a
  7050.   string to it:
  7051.  
  7052.     define append_string_to_file (file, str)
  7053.     {
  7054.        variable fp = fopen (file, "a");
  7055.        if (fp == NULL)
  7056.          throw OpenError, "$file could not be opened"$;
  7057.        () = fputs (string, fp);
  7058.        () = fclose (fp);
  7059.     }
  7060.  
  7061.   Note that the return values from `fputs' and `fclose' were
  7062.   ignored.
  7063.  
  7064.  NOTES
  7065.   There is no need to explicitly close a file opened with `fopen'.
  7066.   If the returned File_Type object goes out of scope, the
  7067.   interpreter will automatically close the file.  However, explicitly
  7068.   closing a file with `fclose' and checking its return value is
  7069.   recommended.
  7070.  
  7071.  SEE ALSO
  7072.   fclose, fgets, fputs, popen
  7073.  
  7074. --------------------------------------------------------------
  7075.  
  7076. fprintf
  7077.  
  7078.  SYNOPSIS
  7079.   Create and write a formatted string to a file
  7080.  
  7081.  USAGE
  7082.   Int_Type fprintf (File_Type fp, String_Type fmt, ...)
  7083.  
  7084.  DESCRIPTION
  7085.   `fprintf' formats the objects specified by the variable argument
  7086.   list according to the format `fmt' and write the result to the
  7087.   open file pointer `fp'.
  7088.  
  7089.   The format string obeys the same syntax and semantics as the
  7090.   `sprintf' format string.  See the description of the
  7091.   `sprintf' function for more information.
  7092.  
  7093.   `fprintf' returns the number of bytes written to the file,
  7094.   or -1 upon error.
  7095.  
  7096.  SEE ALSO
  7097.   fputs, printf, fwrite, message
  7098.  
  7099. --------------------------------------------------------------
  7100.  
  7101. fputs
  7102.  
  7103.  SYNOPSIS
  7104.   Write a string to an open stream
  7105.  
  7106.  USAGE
  7107.   Integer_Type fputs (String_Type s, File_Type fp)
  7108.  
  7109.  DESCRIPTION
  7110.   The `fputs' function writes the string `s' to the open file
  7111.   pointer `fp'. It returns -1 upon failure and sets `errno',
  7112.   otherwise it returns the length of the string.
  7113.  
  7114.  EXAMPLE
  7115.   The following function opens a file in append mode and uses the
  7116.   `fputs' function to write to it.
  7117.  
  7118.     define append_string_to_file (str, file)
  7119.     {
  7120.        variable fp;
  7121.        fp = fopen (file, "a");
  7122.        if (fp == NULL)
  7123.          throw OpenError, "Unable to open $file"$;
  7124.        if ((-1 == fputs (s, fp))
  7125.            or (-1 == fclose (fp)))
  7126.          throw WriteError, "Error writing to $file";
  7127.     }
  7128.  
  7129.  
  7130.  NOTES
  7131.   One must not disregard the return value from the `fputs'
  7132.   function.  Doing so may lead to a stack overflow error.
  7133.  
  7134.   To write an object that contains embedded null characters, use the
  7135.   `fwrite' function.
  7136.  
  7137.  SEE ALSO
  7138.   fclose, fopen, fgets, fwrite
  7139.  
  7140. --------------------------------------------------------------
  7141.  
  7142. fputslines
  7143.  
  7144.  SYNOPSIS
  7145.   Write an array of strings to an open file
  7146.  
  7147.  USAGE
  7148.   Int_Type fputslines (String_Type[]a, File_Type fp)
  7149.  
  7150.  DESCRIPTION
  7151.   The `fputslines' function writes an array of strings to the
  7152.   specified file pointer.  It returns the number of elements
  7153.   successfully written.  Any NULL elements in the array will be
  7154.   skipped.
  7155.  
  7156.  EXAMPLE
  7157.  
  7158.     if (length (lines) != fputslines (fp, lines))
  7159.       throw WriteError;
  7160.  
  7161.  
  7162.  SEE ALSO
  7163.   fputs, fgetslines, fopen
  7164.  
  7165. --------------------------------------------------------------
  7166.  
  7167. fread
  7168.  
  7169.  SYNOPSIS
  7170.   Read binary data from a file
  7171.  
  7172.  USAGE
  7173.   UInt_Type fread (Ref_Type b, DataType_Type t, UInt_Type n, File_Type fp)
  7174.  
  7175.  DESCRIPTION
  7176.   The `fread' function may be used to read `n' objects of type
  7177.   `t' from an open file pointer `fp'.  Upon success, it
  7178.   returns the number of objects read from the file and places the
  7179.   objects in variable specified by `b'.  Upon error or
  7180.   end-of-file, it returns -1 and sets `errno' accordingly.
  7181.  
  7182.   If more than one object is read from the file, those objects will be
  7183.   placed in an array of the appropriate size.
  7184.  
  7185.  EXAMPLE
  7186.   The following example illustrates how to read 50 integers from a file:
  7187.  
  7188.      define read_50_ints_from_a_file (file)
  7189.      {
  7190.         variable fp, n, buf;
  7191.  
  7192.         fp = fopen (file, "rb");
  7193.         if (fp == NULL)
  7194.           throw OpenError;
  7195.         n = fread (&buf, Int_Type, 50, fp);
  7196.         if (n == -1)
  7197.           throw ReadError, "fread failed";
  7198.         () = fclose (fp);
  7199.         return buf;
  7200.      }
  7201.  
  7202.  
  7203.  NOTES
  7204.   Use the `pack' and `unpack' functions to read data with a
  7205.   specific byte-ordering.
  7206.  
  7207.   The `fread_bytes' function may be used to read a specified number of
  7208.   bytes in the form of a binary string (`BString_Type').
  7209.  
  7210.   If an attempt is made to read at the end of a file, the function
  7211.   will return -1.  To distinguish this condition from a system error,
  7212.   the `feof' function should be used.  This distinction is
  7213.   particularly important when reading from a socket or pipe.
  7214.  
  7215.  SEE ALSO
  7216.   fread_bytes, fwrite, fgets, feof, ferror, fopen, pack, unpack
  7217.  
  7218. --------------------------------------------------------------
  7219.  
  7220. fread_bytes
  7221.  
  7222.  SYNOPSIS
  7223.   Read bytes from a file as a binary-string
  7224.  
  7225.  USAGE
  7226.   UInt_Type fread_bytes (Ref_Type b, UInt_Type n, File_Type fp)
  7227.  
  7228.  DESCRIPTION
  7229.   The `fread_bytes' function may be used to read `n' bytes
  7230.   from from an open file pointer `fp'.  Upon success, it returns
  7231.   the number of bytes read from the file and assigns to the variable
  7232.   attached to the reference `b' a binary string formed from the
  7233.   bytes read.  Upon error or end of file, the function returns
  7234.   -1 and sets `errno' accordingly.
  7235.  
  7236.  NOTES
  7237.   Use the `pack' and `unpack' functions to read data with a
  7238.   specific byte-ordering.
  7239.  
  7240.  SEE ALSO
  7241.   fread, fwrite, fgets, fopen, pack, unpack
  7242.  
  7243. --------------------------------------------------------------
  7244.  
  7245. fseek
  7246.  
  7247.  SYNOPSIS
  7248.   Reposition a stdio stream
  7249.  
  7250.  USAGE
  7251.   Integer_Type fseek (File_Type fp, LLong_Type ofs, Integer_Type whence
  7252.  
  7253.  DESCRIPTION
  7254.   The `fseek' function may be used to reposition the file position
  7255.   pointer associated with the open file stream `fp'. Specifically,
  7256.   it moves the pointer `ofs' bytes relative to the position
  7257.   indicated by `whence'.  If `whence' is set to one of the symbolic
  7258.   constants SEEK_SET, SEEK_CUR, or SEEK_END, the
  7259.   offset is relative to the start of the file, the current position
  7260.   indicator, or end-of-file, respectively.
  7261.  
  7262.   The function returns 0 upon success, or -1 upon failure and sets
  7263.   `errno' accordingly.
  7264.  
  7265.  EXAMPLE
  7266.     define rewind (fp)
  7267.     {
  7268.        if (0 == fseek (fp, 0, SEEK_SET)) return;
  7269.        vmessage ("rewind failed, reason: %s", errno_string (errno));
  7270.     }
  7271.  
  7272.  SEE ALSO
  7273.   ftell, fopen
  7274.  
  7275. --------------------------------------------------------------
  7276.  
  7277. ftell
  7278.  
  7279.  SYNOPSIS
  7280.   Obtain the current position in an open stream
  7281.  
  7282.  USAGE
  7283.   LLong_Type ftell (File_Type fp)
  7284.  
  7285.  DESCRIPTION
  7286.   The ftell function may be used to obtain the current position in the
  7287.   stream associated with the open file pointer `fp'.  It returns
  7288.   the position of the pointer measured in bytes from the beginning of
  7289.   the file.  Upon error, it returns `-1' and sets `errno'
  7290.   accordingly.
  7291.  
  7292.  SEE ALSO
  7293.   fseek, fopen
  7294.  
  7295. --------------------------------------------------------------
  7296.  
  7297. fwrite
  7298.  
  7299.  SYNOPSIS
  7300.   Write binary data to a file
  7301.  
  7302.  USAGE
  7303.   UInt_Type fwrite (b, File_Type fp)
  7304.  
  7305.  DESCRIPTION
  7306.   The `fwrite' function may be used to write the object represented by
  7307.   `b' to an open file.  If `b' is a string or an array, the
  7308.   function will attempt to write all elements of the object to the
  7309.   file.  It returns the number of elements successfully written,
  7310.   otherwise it returns -1 upon error and sets `errno'
  7311.   accordingly.
  7312.  
  7313.  EXAMPLE
  7314.   The following example illustrates how to write an integer array to a
  7315.   file.  In this example, `fp' is an open file descriptor:
  7316.  
  7317.      variable a = [1:50];     % 50 element integer array
  7318.      if (50 != fwrite (a, fp))
  7319.        throw WriteError;
  7320.  
  7321.   Here is how to write the array one element at a time:
  7322.  
  7323.      variable ai, a = [1:50];
  7324.  
  7325.      foreach ai (a)
  7326.        {
  7327.           if (1 != fwrite(ai, fp))
  7328.             throw WriteError;
  7329.        }
  7330.  
  7331.  
  7332.  NOTES
  7333.   Not all data types may be supported the `fwrite' function.  It
  7334.   is supported by all vector, scalar, and string objects.
  7335.  
  7336.  SEE ALSO
  7337.   fread, fputs, fopen, pack, unpack
  7338.  
  7339. --------------------------------------------------------------
  7340.  
  7341. pclose
  7342.  
  7343.  SYNOPSIS
  7344.   Close a process pipe
  7345.  
  7346.  USAGE
  7347.   Integer_Type pclose (File_Type fp)
  7348.  
  7349.  DESCRIPTION
  7350.   The `pclose' function waits for the process associated with
  7351.   `fp' to exit and the returns the exit status of the command.
  7352.  
  7353.  SEE ALSO
  7354.   pclose, fclose
  7355.  
  7356. --------------------------------------------------------------
  7357.  
  7358. popen
  7359.  
  7360.  SYNOPSIS
  7361.   Open a pipe to a process
  7362.  
  7363.  USAGE
  7364.   File_Type popen (String_Type cmd, String_Type mode)
  7365.  
  7366.  DESCRIPTION
  7367.   The `popen' function executes a process specified by `cmd'
  7368.   and opens a unidirectional pipe to the newly created process.  The
  7369.   `mode' indicates whether or not the pipe is open for reading
  7370.   or writing.  Specifically, if `mode' is `"r"', then the
  7371.   pipe is opened for reading, or if `mode' is `"w"', then the
  7372.   pipe will be open for writing.
  7373.  
  7374.   Upon success, a File_Type pointer will be returned, otherwise
  7375.   the function failed and NULL will be returned.
  7376.  
  7377.  NOTES
  7378.   This function is not available on all systems.
  7379.  
  7380.  The `process' module's `new_process' function provides a
  7381.  much more secure and powerful interface to process I/O.
  7382.  
  7383.  SEE ALSO
  7384.   new_process, pclose, fopen
  7385.  
  7386. --------------------------------------------------------------
  7387.  
  7388. printf
  7389.  
  7390.  SYNOPSIS
  7391.   Create and write a formatted string to stdout
  7392.  
  7393.  USAGE
  7394.   Int_Type printf (String_Type fmt, ...)
  7395.  
  7396.  DESCRIPTION
  7397.   `printf' formats the objects specified by the variable argument
  7398.   list according to the format `fmt' and write the result to
  7399.   `stdout'.  This function is equivalent to `fprintf' used
  7400.   with the `stdout' file pointer.  See `fprintf' for more
  7401.   information.
  7402.  
  7403.   `printf' returns the number of bytes written or -1 upon error.
  7404.  
  7405.  NOTES
  7406.   Many C programmers do not check the return status of the
  7407.   `printf' C library function.  Make sure that if you do not care
  7408.   about whether or not the function succeeds, then code it as in the
  7409.   following example:
  7410.  
  7411.      () = printf ("%s laid %d eggs\n", chicken_name, num_egg);
  7412.  
  7413.  
  7414.  SEE ALSO
  7415.   fputs, fprintf, fwrite, message
  7416.  
  7417. --------------------------------------------------------------
  7418.  
  7419. count_char_occurances
  7420.  
  7421.  SYNOPSIS
  7422.   Count the number of occurances of a character in a string
  7423.  
  7424.  USAGE
  7425.   UInt_Type count_char_occurances (str, ch)
  7426.  
  7427.  DESCRIPTION
  7428.   This function returns the number of times the specified character
  7429.   `ch' occurs in the string `str'.
  7430.  
  7431.  NOTES
  7432.   If UTF-8 mode is in effect, then the character may correspond to
  7433.   more than one byte.  In such a case, the function returns the number
  7434.   of such byte-sequences in the string.  To count actual bytes, use
  7435.   the `count_byte_occurances' function.
  7436.  
  7437.  SEE ALSO
  7438.   count_byte_occurances
  7439.  
  7440. --------------------------------------------------------------
  7441.  
  7442. create_delimited_string
  7443.  
  7444.  SYNOPSIS
  7445.   Concatenate strings using a delimiter
  7446.  
  7447.  USAGE
  7448.   String_Type create_delimited_string (delim, s_1, s_2, ..., s_n, n)
  7449.  
  7450.     String_Type delim, s_1, ..., s_n
  7451.     Int_Type n
  7452.  
  7453.  
  7454.  DESCRIPTION
  7455.   `create_delimited_string' performs a concatenation operation on
  7456.   the `n' strings `s_1', ...,`s_n', using the string
  7457.   `delim' as a delimiter.  The resulting string is equivalent to
  7458.   one obtained via
  7459.  
  7460.       s_1 + delim + s_2 + delim + ... + s_n
  7461.  
  7462.  
  7463.  EXAMPLE
  7464.  
  7465.     create_delimited_string ("/", "user", "local", "bin", 3);
  7466.  
  7467.   will produce `"usr/local/bin"'.
  7468.  
  7469.  NOTES
  7470.   New code should use the `strjoin' function, which performs a
  7471.   similar task.
  7472.  
  7473.  SEE ALSO
  7474.   strjoin, is_list_element, extract_element, strchop, strcat
  7475.  
  7476. --------------------------------------------------------------
  7477.  
  7478. extract_element
  7479.  
  7480.  SYNOPSIS
  7481.   Extract the nth element of a string with delimiters
  7482.  
  7483.  USAGE
  7484.   String_Type extract_element (String_Type list, Int_Type nth, Int_Type delim)
  7485.  
  7486.  DESCRIPTION
  7487.   The `extract_element' function may be used to extract the
  7488.   `nth' substring of a string delimited by the character given by
  7489.   the `delim' parameter.  If the string contains fewer than the
  7490.   requested substring, the function will return NULL.  Substring
  7491.   elements are numbered from 0.
  7492.  
  7493.  EXAMPLE
  7494.   The expression
  7495.  
  7496.      extract_element ("element 0, element 1, element 2", 1, ',')
  7497.  
  7498.   returns the string `" element 1"', whereas
  7499.  
  7500.      extract_element ("element 0, element 1, element 2", 1, ' ')
  7501.  
  7502.   returns `"0,"'.
  7503.  
  7504.   The following function may be used to compute the number of elements
  7505.   in the list:
  7506.  
  7507.      define num_elements (list, delim)
  7508.      {
  7509.         variable nth = 0;
  7510.         while (NULL != extract_element (list, nth, delim))
  7511.           nth++;
  7512.         return nth;
  7513.      }
  7514.  
  7515.   Alternatively, the `strchop' function may be more useful.  In
  7516.   fact, `extract_element' may be expressed in terms of the
  7517.   function `strchop' as
  7518.  
  7519.     define extract_element (list, nth, delim)
  7520.     {
  7521.        list = strchop(list, delim, 0);
  7522.        if (nth >= length (list))
  7523.          return NULL;
  7524.        else
  7525.          return list[nth];
  7526.     }
  7527.  
  7528.    and the `num_elements' function used above may be recoded more
  7529.    simply as:
  7530.  
  7531.     define num_elements (list, delim)
  7532.     {
  7533.        return length (strchop (length, delim, 0));
  7534.     }
  7535.  
  7536.  
  7537.  NOTES
  7538.   New code should make use of the `List_Type' object for lists.
  7539.  
  7540.  SEE ALSO
  7541.   is_list_element, is_substr, strtok, strchop, create_delimited_string
  7542.  
  7543. --------------------------------------------------------------
  7544.  
  7545. glob_to_regexp
  7546.  
  7547.  SYNOPSIS
  7548.   Convert a globbing expression to a regular expression
  7549.  
  7550.  USAGE
  7551.   String_Type glob_to_regexp (String_Type g)
  7552.  
  7553.  DESCRIPTION
  7554.   This function may be used to convert a so-called globbing expression
  7555.   to a regular expression.  A globbing expression is frequently used
  7556.   for matching filenames where '?' represents a single character and
  7557.   '*' represents 0 or more characters.
  7558.  
  7559.  NOTES
  7560.   The `slsh' program that is distributed with the S-Lang library
  7561.   includes a function called `glob' that is a wrapper around
  7562.   `glob_to_regexp' and `listdir'.  It returns a list of
  7563.   filenames matching a globbing expression.
  7564.  
  7565.  SEE ALSO
  7566.   string_match, listdir
  7567.  
  7568. --------------------------------------------------------------
  7569.  
  7570. is_list_element
  7571.  
  7572.  SYNOPSIS
  7573.   Test whether a delimited string contains a specific element
  7574.  
  7575.  USAGE
  7576.   Int_Type is_list_element (String_Type list, String_Type elem, Int_Type delim)
  7577.  
  7578.  DESCRIPTION
  7579.   The `is_list_element' function may be used to determine whether
  7580.   or not a delimited list of substring, `list', contains the element
  7581.   `elem'.  If `elem' is not an element of `list', the function
  7582.   will return zero, otherwise, it returns 1 plus the matching element
  7583.   number.
  7584.  
  7585.  EXAMPLE
  7586.   The expression
  7587.  
  7588.      is_list_element ("element 0, element 1, element 2", "0,", ' ');
  7589.  
  7590.   returns `2' since `"0,"' is element number one of the list
  7591.   (numbered from zero).
  7592.  
  7593.  SEE ALSO
  7594.   extract_element, is_substr, create_delimited_string
  7595.  
  7596. --------------------------------------------------------------
  7597.  
  7598. is_substr
  7599.  
  7600.  SYNOPSIS
  7601.   Test for a specified substring within a string
  7602.  
  7603.  USAGE
  7604.   Int_Type is_substr (String_Type a, String_Type b)
  7605.  
  7606.  DESCRIPTION
  7607.   This function may be used to determine if `a' contains the
  7608.   string `b'.  If it does not, the function returns 0; otherwise it
  7609.   returns the position of the first occurrence of `b' in `a'
  7610.   expressed in terms of characters, not bytes.
  7611.  
  7612.  NOTES
  7613.   This function regards the first character of a string to be given by
  7614.   a position value of 1.
  7615.  
  7616.   The distinction between characters and bytes is significant in UTF-8
  7617.   mode.
  7618.  
  7619.  SEE ALSO
  7620.   substr, string_match, strreplace
  7621.  
  7622. --------------------------------------------------------------
  7623.  
  7624. make_printable_string
  7625.  
  7626.  SYNOPSIS
  7627.   Format a string suitable for parsing
  7628.  
  7629.  USAGE
  7630.   String_Type make_printable_string(String_Type str)
  7631.  
  7632.  DESCRIPTION
  7633.   This function formats a string in such a way that it may be used as
  7634.   an argument to the `eval' function.  The resulting string is
  7635.   identical to `str' except that it is enclosed in double quotes
  7636.   and the backslash, newline, control, and double quote characters are
  7637.   expanded.
  7638.  
  7639.  SEE ALSO
  7640.   eval, str_quote_string
  7641.  
  7642. --------------------------------------------------------------
  7643.  
  7644. Sprintf
  7645.  
  7646.  SYNOPSIS
  7647.   Format objects into a string (deprecated)
  7648.  
  7649.  USAGE
  7650.   String_Type Sprintf (String_Type format, ..., Int_Type n)
  7651.  
  7652.  DESCRIPTION
  7653.   This function performs a similar task as the `sprintf'
  7654.   function but requires an additional argument that specifies the
  7655.   number of items to format.  For this reason, the `sprintf'
  7656.   function should be used.
  7657.  
  7658.  SEE ALSO
  7659.   sprintf, string, sscanf, vmessage
  7660.  
  7661. --------------------------------------------------------------
  7662.  
  7663. sprintf
  7664.  
  7665.  SYNOPSIS
  7666.   Format objects into a string
  7667.  
  7668.  USAGE
  7669.   String_Type sprintf (String fmt, ...)
  7670.  
  7671.  DESCRIPTION
  7672.   The `sprintf' function formats a string from a variable number
  7673.   of arguments according to according to the format specification
  7674.   string `fmt'.
  7675.  
  7676.   The format string is a C library `sprintf' style format
  7677.   descriptor.  Briefly, the format string may consist of ordinary
  7678.   characters (not including the `%' character), which are copied
  7679.   into the output string as-is, and conversion specification sequences
  7680.   introduced by the `%' character.  The number of additional
  7681.   arguments passed to the `sprintf' function must be consistent
  7682.   with the number required by the format string.
  7683.  
  7684.   The `%' character in the format string starts a conversion
  7685.   specification that indicates how an object is to be formatted.
  7686.   Usually the percent character is followed immediately by a
  7687.   conversion specification character.  However, it may optionally be
  7688.   followed by flag characters, field width characters, and precision
  7689.   modifiers, as described below.
  7690.  
  7691.   The character immediately following the `%' character may be
  7692.   one or more of the following flag characters:
  7693.  
  7694.     -         Use left-justification
  7695.     #         Use alternate form for formatting.
  7696.     0         Use 0 padding
  7697.     +         Preceed a number by a plus or minus sign.
  7698.     (space)   Use a blank instead of a plus sign.
  7699.  
  7700.  
  7701.   The flag characters (if any) may be followed by an optional field
  7702.   width specification string represented by one or more digit
  7703.   characters.  If the size of the formatted object is less than the
  7704.   field width, it will be right-justified in the specified field
  7705.   width, unless the `-' flag was given, in which case it will be
  7706.   left justified.
  7707.  
  7708.   If the next character in the control sequence is a period, then it
  7709.   introduces a precision specification sequence.  The precision is
  7710.   given by the digit characters following the period.  If none are
  7711.   given the precision is taken to be 0.  The meaning of the precision
  7712.   specifier depends upon the type of conversion:  For integer
  7713.   conversions, it gives the minimum number digits to appear in the
  7714.   output.  For `e' and `f' floating point conversions, it
  7715.   gives the number of digits to appear after the decimal point.  For
  7716.   the `g' floating point conversion, it gives the maximum number
  7717.   of significant digits to appear.  Finally for the `s' and
  7718.   `S' conversions it specifies the maximum number of characters
  7719.   to be copied to the output string.
  7720.  
  7721.   The next character in the sequence may be a modifier that controls
  7722.   the size of object to be formatted. It may consist of the following
  7723.   characters:
  7724.  
  7725.      h    This character is ignored in the current implementation.
  7726.      l    The integer is be formatted as a long integer, or a
  7727.           character as a wide character.
  7728.  
  7729.  
  7730.   Finally the conversion specification sequence ends with the
  7731.   conversion specification character that describes how the object is
  7732.   to be
  7733.   formatted:
  7734.  
  7735.      s    as a string
  7736.      f    as a floating point number
  7737.      e    as a float using exponential form, e.g., 2.345e08
  7738.      g    format as e or g, depending upon its value
  7739.      c    as a character
  7740.      b    as a byte
  7741.      %    a literal percent character
  7742.      d    as a signed decimal integer
  7743.      u    as an unsigned decimal integer
  7744.      o    as an octal integer
  7745.      X    as hexadecimal
  7746.      S    convert object to a string and format accordingly
  7747.  
  7748.   The `S' conversion specifier is a S-Lang extension which will
  7749.   cause the corresponding object to be converted to a string using the
  7750.   `string' function, and then converted as `s'. formatted as
  7751.   string.  In fact, `sprintf("%S",x)' is equivalent to
  7752.   `sprintf("%s",string(x))'.
  7753.  
  7754.  EXAMPLE
  7755.  
  7756.     sprintf("%s","hello")               ===> "hello"
  7757.     sprintf("%s %s","hello", "world")   ===> "hello world"
  7758.     sprintf("Agent %.3d",7)             ===> "Agent 007"
  7759.     sprintf("%S",PI)                    ===> "3.141592653589793"
  7760.     sprintf("%g",PI)                    ===> "3.14159"
  7761.     sprintf("%.2g",PI)                  ===> "3.1"
  7762.     sprintf("%.2e",PI)                  ===> "3.14e+00"
  7763.     sprintf("%.2f",PI)                  ===> "3.14"
  7764.     sprintf("|% 8.2f|",PI)              ===> "|    3.14|"
  7765.     sprintf("|%-8.2f|",PI)              ===> "|3.14    |"
  7766.     sprintf("|%+8.2f|",PI)              ===> "|   +3.14|"
  7767.     sprintf("%S",{1,2,3})               ===> "List_Type with 3 elements"
  7768.     sprintf("%S",1+2i)                  ===> "(1 + 2i)"
  7769.  
  7770.  
  7771.  NOTES
  7772.   The `set_float_format' function controls the format for the
  7773.   `S' conversion of floating point numbers.
  7774.  
  7775.  SEE ALSO
  7776.   string, sscanf, message, pack
  7777.  
  7778. --------------------------------------------------------------
  7779.  
  7780. sscanf
  7781.  
  7782.  SYNOPSIS
  7783.   Parse a formatted string
  7784.  
  7785.  USAGE
  7786.   Int_Type sscanf (s, fmt, r1, ... rN)
  7787.  
  7788.     String_Type s, fmt;
  7789.     Ref_Type r1, ..., rN
  7790.  
  7791.  
  7792.  DESCRIPTION
  7793.  The `sscanf' function parses the string `s' according to the
  7794.  format `fmt' and sets the variables whose references are given by
  7795.  `r1', ..., `rN'.  The function returns the number of
  7796.  references assigned, or throws an exception upon error.
  7797.  
  7798.  The format string `fmt' consists of ordinary characters and
  7799.  conversion specifiers.  A conversion specifier begins with the
  7800.  special character `%' and is described more fully below.  A white
  7801.  space character in the format string matches any amount of whitespace
  7802.  in the input string.  Parsing of the format string stops whenever a
  7803.  match fails.
  7804.  
  7805.  The `%' character is used to denote a conversion specifier whose
  7806.  general form is given by `%[*][width][type]format' where the
  7807.  brackets indicate optional items.  If `*' is present, then the
  7808.  conversion will be performed but no assignment to a reference will be
  7809.  made.  The `width' specifier specifies the maximum field width to
  7810.  use for the conversion.  The `type' modifier is used to indicate
  7811.  the size of the object, e.g., a short integer, as follows.
  7812.  
  7813.  If _type_ is given as the character `h', then if the format
  7814.  conversion is for an integer (`dioux'), the object assigned will
  7815.  be a short integer.  If _type_ is `l', then the conversion
  7816.  will be to a long integer for integer conversions, or to a double
  7817.  precision floating point number for floating point conversions.
  7818.  
  7819.  The format specifier is a character that specifies the conversion:
  7820.  
  7821.        %     Matches a literal percent character.  No assignment is
  7822.              performed.
  7823.        d     Matches a signed decimal integer.
  7824.        D     Matches a long decimal integer (equiv to `ld')
  7825.        u     Matches an unsigned decimal integer
  7826.        U     Matches an unsigned long decimal integer (equiv to `lu')
  7827.        i     Matches either a hexadecimal integer, decimal integer, or
  7828.              octal integer.
  7829.        I     Equivalent to `li'.
  7830.        x     Matches a hexadecimal integer.
  7831.        X     Matches a long hexadecimal integer (same as `lx').
  7832.        e,f,g Matches a decimal floating point number (Float_Type).
  7833.        E,F,G Matches a double precision floating point number, same as `lf'.
  7834.        s     Matches a string of non-whitespace characters (String_Type).
  7835.        c     Matches one character.  If width is given, width
  7836.              characters are matched.
  7837.        n     Assigns the number of characters scanned so far.
  7838.        [...] Matches zero or more characters from the set of characters
  7839.              enclosed by the square brackets.  If '^' is given as the
  7840.              first character, then the complement set is matched.
  7841.  
  7842.  
  7843.  EXAMPLE
  7844.  Suppose that `s' is `"Coffee: (3,4,12.4)"'.  Then
  7845.  
  7846.     n = sscanf (s, "%[a-zA-Z]: (%d,%d,%lf)", &item, &x, &y, &z);
  7847.  
  7848.  will set `n' to 4, `item' to `"Coffee"', `x' to 3,
  7849.  `y' to 4, and `z' to the double precision number
  7850.  `12.4'.  However,
  7851.  
  7852.     n = sscanf (s, "%s: (%d,%d,%lf)", &item, &x, &y, &z);
  7853.  
  7854.  will set `n' to 1, `item' to `"Coffee:"' and the
  7855.  remaining variables will not be assigned.
  7856.  
  7857.  SEE ALSO
  7858.   sprintf, unpack, string, atof, int, integer, string_matches
  7859.  
  7860. --------------------------------------------------------------
  7861.  
  7862. strbytelen
  7863.  
  7864.  SYNOPSIS
  7865.   Get the number of bytes in a string
  7866.  
  7867.  USAGE
  7868.   Int_Type strbytelen (String_Type s)
  7869.  
  7870.  DESCRIPTION
  7871.   This function returns the number of bytes in a string.  In UTF-8
  7872.   mode, this value is generally different from the number of
  7873.   characters in a string.  For the latter information, the
  7874.   `strlen' or `strcharlen' functions should be used.
  7875.  
  7876.  SEE ALSO
  7877.   strlen, strcharlen, length
  7878.  
  7879. --------------------------------------------------------------
  7880.  
  7881. strbytesub
  7882.  
  7883.  SYNOPSIS
  7884.   Replace a byte with another in a string.
  7885.  
  7886.  USAGE
  7887.   String_Type strsub (String_Type s, Int_Type pos, UChar_Type b)
  7888.  
  7889.  DESCRIPTION
  7890.   The `strbytesub' function may be be used to substitute the byte
  7891.   `b' for the byte at byte position `pos' of the string
  7892.   `s'.  The resulting string is returned.
  7893.  
  7894.  NOTES
  7895.   The first byte in the string `s' is specified by `pos'
  7896.   equal to 1.  This function uses byte semantics, not character
  7897.   semantics.
  7898.  
  7899.  SEE ALSO
  7900.   strsub, is_substr, strreplace, strbytelen
  7901.  
  7902. --------------------------------------------------------------
  7903.  
  7904. strcat
  7905.  
  7906.  SYNOPSIS
  7907.   Concatenate strings
  7908.  
  7909.  USAGE
  7910.   String_Type strcat (String_Type a_1, ...,  String_Type a_N)
  7911.  
  7912.  DESCRIPTION
  7913.    The `strcat' function concatenates its N string
  7914.    arguments `a_1', ... `a_N' together and returns the result.
  7915.  
  7916.  EXAMPLE
  7917.  
  7918.     strcat ("Hello", " ", "World");
  7919.  
  7920.    produces the string `"Hello World"'.
  7921.  
  7922.  NOTES
  7923.    This function is equivalent to the binary operation `a_1+...+a_N'.
  7924.    However, `strcat' is much faster making it the preferred method
  7925.    to concatenate strings.
  7926.  
  7927.  SEE ALSO
  7928.   sprintf, strjoin
  7929.  
  7930. --------------------------------------------------------------
  7931.  
  7932. strcharlen
  7933.  
  7934.  SYNOPSIS
  7935.   Get the number of characters in a string including combining characters
  7936.  
  7937.  USAGE
  7938.   Int_Type strcharlen (String_Type s)
  7939.  
  7940.  DESCRIPTION
  7941.   The `strcharlen' function returns the number of characters in a
  7942.   string.  If the string contains combining characters, then they are
  7943.   also counted.  Use the `strlen' function to obtain the
  7944.   character count ignoring combining characters.
  7945.  
  7946.  SEE ALSO
  7947.   strlen, strbytelen
  7948.  
  7949. --------------------------------------------------------------
  7950.  
  7951. strchop
  7952.  
  7953.  SYNOPSIS
  7954.   Chop or split a string into substrings.
  7955.  
  7956.  USAGE
  7957.   String_Type[] strchop (String_Type str, Int_Type delim, Int_Type quote)
  7958.  
  7959.  DESCRIPTION
  7960.    The `strchop' function may be used to split-up a string
  7961.    `str' that consists of substrings delimited by the character
  7962.    specified by `delim'.  If the integer `quote' is non-zero,
  7963.    it will be taken as a quote character for the delimiter.  The
  7964.    function returns the substrings as an array.
  7965.  
  7966.  EXAMPLE
  7967.    The following function illustrates how to sort a comma separated
  7968.    list of strings:
  7969.  
  7970.      define sort_string_list (a)
  7971.      {
  7972.         variable i, b, c;
  7973.         b = strchop (a, ',', 0);
  7974.  
  7975.         i = array_sort (b);
  7976.         b = b[i];   % rearrange
  7977.  
  7978.         % Convert array back into comma separated form
  7979.         return strjoin (b, ",");
  7980.      }
  7981.  
  7982.  
  7983.  SEE ALSO
  7984.   strchopr, strjoin, strtok
  7985.  
  7986. --------------------------------------------------------------
  7987.  
  7988. strchopr
  7989.  
  7990.  SYNOPSIS
  7991.   Chop or split a string into substrings.
  7992.  
  7993.  USAGE
  7994.   String_Type[] strchopr (String_Type str, String_Type delim, String_Type quote)
  7995.  
  7996.  DESCRIPTION
  7997.   This routine performs exactly the same function as `strchop' except
  7998.   that it returns the substrings in the reverse order.  See the
  7999.   documentation for `strchop' for more information.
  8000.  
  8001.  SEE ALSO
  8002.   strchop, strtok, strjoin
  8003.  
  8004. --------------------------------------------------------------
  8005.  
  8006. strcmp
  8007.  
  8008.  SYNOPSIS
  8009.   Compare two strings
  8010.  
  8011.  USAGE
  8012.   Int_Type strcmp (String_Type a, String_Type b)
  8013.  
  8014.  DESCRIPTION
  8015.    The `strcmp' function may be used to perform a case-sensitive
  8016.    string comparison, in the lexicographic sense, on strings `a' and
  8017.    `b'.  It returns 0 if the strings are identical, a negative integer
  8018.    if `a' is less than `b', or a positive integer if `a' is greater
  8019.    than `b'.
  8020.  
  8021.  EXAMPLE
  8022.    The `strup' function may be used to perform a case-insensitive
  8023.    string comparison:
  8024.  
  8025.     define case_insensitive_strcmp (a, b)
  8026.     {
  8027.       return strcmp (strup(a), strup(b));
  8028.     }
  8029.  
  8030.  
  8031.  NOTES
  8032.    One may also use one of the binary comparison operators, e.g.,
  8033.    `a > b'.
  8034.  
  8035.  SEE ALSO
  8036.   strup, strncmp
  8037.  
  8038. --------------------------------------------------------------
  8039.  
  8040. strcompress
  8041.  
  8042.  SYNOPSIS
  8043.   Remove excess whitespace characters from a string
  8044.  
  8045.  USAGE
  8046.   String_Type strcompress (String_Type s, String_Type white)
  8047.  
  8048.  DESCRIPTION
  8049.   The `strcompress' function compresses the string `s' by
  8050.   replacing a sequence of one or more characters from the set
  8051.   `white' by the first character of `white'. In addition, it
  8052.   also removes all leading and trailing characters from `s' that
  8053.   are part of `white'.
  8054.  
  8055.  EXAMPLE
  8056.   The expression
  8057.  
  8058.     strcompress (",;apple,,cherry;,banana", ",;");
  8059.  
  8060.   returns the string `"apple,cherry,banana"'.
  8061.  
  8062.  SEE ALSO
  8063.   strtrim, strtrans, str_delete_chars
  8064.  
  8065. --------------------------------------------------------------
  8066.  
  8067. string_match
  8068.  
  8069.  SYNOPSIS
  8070.   Match a string against a regular expression
  8071.  
  8072.  USAGE
  8073.   Int_Type string_match(String_Type str, String_Type pat, Int_Type pos)
  8074.  
  8075.  DESCRIPTION
  8076.   The `string_match' function returns zero if `str' does not
  8077.   match regular expression specified by `pat'.  This function
  8078.   performs the match starting at byte-offset `pos' in the string
  8079.   `str' (numbered from 1).  This function returns the position in
  8080.   bytes (numbered from 1) of the start of the match in `str'.
  8081.   The exact substring matched may be found using
  8082.   `string_match_nth'.
  8083.  
  8084.  NOTES
  8085.   Positions in the string are specified using byte-offsets not
  8086.   character offsets. The value returned by this function is measured
  8087.   from the beginning of the string `str'.
  8088.  
  8089.   The function is not yet UTF-8 aware.  If possible, consider using
  8090.   the `pcre' module for better, more sophisticated regular
  8091.   expressions.
  8092.  
  8093.  SEE ALSO
  8094.   string_matches, string_match_nth, strcmp, strncmp
  8095.  
  8096. --------------------------------------------------------------
  8097.  
  8098. string_match_nth
  8099.  
  8100.  SYNOPSIS
  8101.   Get the result of the last call to string_match
  8102.  
  8103.  USAGE
  8104.   (Int_Type pos, Int_Type len) = string_match_nth(Int_Type nth)
  8105.  
  8106.  DESCRIPTION
  8107.   The `string_match_nth' function returns two integers describing
  8108.   the result of the last call to `string_match'.  It returns both
  8109.   the zero-based byte-position of the `nth' submatch and
  8110.   the length of the match.
  8111.  
  8112.   By convention, `nth' equal to zero means the entire match.
  8113.   Otherwise, `nth' must be an integer with a value 1 through 9,
  8114.   and refers to the set of characters matched by the `nth' regular
  8115.   expression enclosed by the pairs `\(, \)'.
  8116.  
  8117.  EXAMPLE
  8118.   Consider:
  8119.  
  8120.      variable matched, pos, len;
  8121.      matched = string_match("hello world", "\([a-z]+\) \([a-z]+\)"R, 1);
  8122.      if (matched)
  8123.        (pos, len) = string_match_nth(2);
  8124.  
  8125.   This will set `matched' to 1 since a match will be found at the
  8126.   first byte position, `pos' to 6 since `w' is offset 6 bytes
  8127.   from the beginning of the string, and `len' to 5 since
  8128.   `"world"' is 5 bytes long.
  8129.  
  8130.  NOTES
  8131.   The position offset is _not_ affected by the value of the offset
  8132.   parameter to the `string_match' function. For example, if the
  8133.   value of the last parameter to the `string_match' function had
  8134.   been 3, `pos' would still have been set to 6.
  8135.  
  8136.   The `string_matches' function may be used as an alternative to
  8137.   `string_match_nth'.
  8138.  
  8139.  SEE ALSO
  8140.   string_match, string_matches
  8141.  
  8142. --------------------------------------------------------------
  8143.  
  8144. string_matches
  8145.  
  8146.  SYNOPSIS
  8147.   Match a string against a regular expression and return the matches
  8148.  
  8149.  USAGE
  8150.   String_Type[] string_matches(String_Type str, String_Type pat, Int_Type pos)
  8151.  
  8152.  DESCRIPTION
  8153.   The `string_matches' function combines the functionality of
  8154.   `string_match' and `string_match_nth'.  Like
  8155.   `string_match', it matches the test string `str' against
  8156.   the regular expression `pat'.  If the string does not match the
  8157.   pattern the function will return NULL.  Otherwise, the function
  8158.   will return an array of strings whose `ith' element is the string that
  8159.   corresponds to the return value of the `string_match_nth'
  8160.   function.
  8161.  
  8162.  EXAMPLE
  8163.  
  8164.     strs = string_matches ("p0.5keV_27deg.dat",
  8165.                            "p\([0-9.]+\)keV_\([0-9.]+\)deg\.dat"R, 1);
  8166.     % ==> strs[0] = "p0.5keV_27deg.dat"
  8167.     %     strs[1] = "0.5"
  8168.     %     strs[2] = "27"
  8169.  
  8170.     strs = string_matches ("q0.5keV_27deg.dat",
  8171.                            "p\([0-9.]+\)keV_\([0-9.]+\)deg\.dat"R, 1);
  8172.     % ==> strs = NULL
  8173.  
  8174.  
  8175.  NOTES
  8176.   The function is not yet UTF-8 aware.  If possible, consider using
  8177.   the `pcre' module for better, more sophisticated regular
  8178.   expressions.
  8179.  
  8180.  SEE ALSO
  8181.   string_match, string_match_nth, strcmp, strncmp
  8182.  
  8183. --------------------------------------------------------------
  8184.  
  8185. strjoin
  8186.  
  8187.  SYNOPSIS
  8188.   Concatenate elements of a string array
  8189.  
  8190.  USAGE
  8191.   String_Type strjoin (Array_Type a, String_Type delim)
  8192.  
  8193.  DESCRIPTION
  8194.    The `strjoin' function operates on an array of strings by joining
  8195.    successive elements together separated with a delimiter `delim'.
  8196.    If `delim' is the empty string `""', then the result will
  8197.    simply be the concatenation of the elements.
  8198.  
  8199.  EXAMPLE
  8200.    Suppose that
  8201.  
  8202.       days = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"];
  8203.  
  8204.    Then `strjoin (days,"+")' will produce
  8205.    `"Sun+Mon+Tue+Wed+Thu+Fri+Sat+Sun"'.  Similarly,
  8206.    `strjoin (["","",""], "X")' will produce `"XX"'.
  8207.  
  8208.  SEE ALSO
  8209.   strchop, strcat
  8210.  
  8211. --------------------------------------------------------------
  8212.  
  8213. strlen
  8214.  
  8215.  SYNOPSIS
  8216.   Compute the length of a string
  8217.  
  8218.  USAGE
  8219.   Int_Type strlen (String_Type a)
  8220.  
  8221.  DESCRIPTION
  8222.    The `strlen' function may be used to compute the character
  8223.    length of a string ignoring the presence of combining characters.
  8224.    The `strcharlen' function may be used to count combining
  8225.    characters as distinct characters.  For byte-semantics, use the
  8226.    `strbytelen' function.
  8227.  
  8228.  EXAMPLE
  8229.    After execution of
  8230.  
  8231.    variable len = strlen ("hello");
  8232.  
  8233.    `len' will have a value of `5'.
  8234.  
  8235.  SEE ALSO
  8236.   strbytelen, strcharlen, bstrlen, length, substr
  8237.  
  8238. --------------------------------------------------------------
  8239.  
  8240. strlow
  8241.  
  8242.  SYNOPSIS
  8243.   Convert a string to lowercase
  8244.  
  8245.  USAGE
  8246.   String_Type strlow (String_Type s)
  8247.  
  8248.  DESCRIPTION
  8249.   The `strlow' function takes a string `s' and returns another
  8250.   string identical to `s' except that all upper case characters
  8251.   that are contained in `s' are converted converted to lower case.
  8252.  
  8253.  EXAMPLE
  8254.   The function
  8255.  
  8256.     define Strcmp (a, b)
  8257.     {
  8258.       return strcmp (strlow (a), strlow (b));
  8259.     }
  8260.  
  8261.   performs a case-insensitive comparison operation of two strings by
  8262.   converting them to lower case first.
  8263.  
  8264.  SEE ALSO
  8265.   strup, tolower, strcmp, strtrim, define_case
  8266.  
  8267. --------------------------------------------------------------
  8268.  
  8269. strnbytecmp
  8270.  
  8271.  SYNOPSIS
  8272.   Compare the first n bytes of two strings
  8273.  
  8274.  USAGE
  8275.   Int_Type strnbytecmp (String_Type a, String_Type b, Int_Type n)
  8276.  
  8277.  DESCRIPTION
  8278.   This function compares the first `n' bytes of the strings
  8279.   `a' and `b'.  See the documentation for `strcmp' for
  8280.   information about the return value.
  8281.  
  8282.  SEE ALSO
  8283.   strncmp, strncharcmp, strcmp
  8284.  
  8285. --------------------------------------------------------------
  8286.  
  8287. strncharcmp
  8288.  
  8289.  SYNOPSIS
  8290.   Compare the first n characters of two strings
  8291.  
  8292.  USAGE
  8293.   Int_Type strncharcmp (String_Type a, String_Type b, Int_Type n)
  8294.  
  8295.  DESCRIPTION
  8296.   This function compares the first `n' characters of the strings
  8297.   `a' and `b' counting combining characters as distinct
  8298.   characters.  See the documentation for `strcmp' for information
  8299.   about the return value.
  8300.  
  8301.  SEE ALSO
  8302.   strncmp, strnbytecmp, strcmp
  8303.  
  8304. --------------------------------------------------------------
  8305.  
  8306. strncmp
  8307.  
  8308.  SYNOPSIS
  8309.   Compare the first few characters of two strings
  8310.  
  8311.  USAGE
  8312.   Int_Type strncmp (String_Type a, String_Type b, Int_Type n)
  8313.  
  8314.  DESCRIPTION
  8315.   This function behaves like `strcmp' except that it compares only the
  8316.   first `n' characters in the strings `a' and `b'.
  8317.   See the documentation for `strcmp' for information about the return
  8318.   value.
  8319.  
  8320.   In counting characters, combining characters are not counted,
  8321.   although they are used in the comparison.  Use the
  8322.   `strncharcmp' function if you want combining characters to be
  8323.   included in the character count.  The `strnbytecmp' function
  8324.   should be used to compare bytes.
  8325.  
  8326.  EXAMPLE
  8327.   The expression
  8328.  
  8329.      strcmp ("apple", "appliance", 3);
  8330.  
  8331.   will return zero since the first three characters match.
  8332.  
  8333.  NOTES
  8334.   This function uses character semantics.
  8335.  
  8336.  SEE ALSO
  8337.   strcmp, strlen, strncharcmp, strnbytecmp
  8338.  
  8339. --------------------------------------------------------------
  8340.  
  8341. strreplace
  8342.  
  8343.  SYNOPSIS
  8344.   Replace one or more substrings
  8345.  
  8346.  USAGE
  8347.   (new, n) = strreplace (a, b, c, max_n)
  8348.  
  8349.    String_Type a, b, c, rep;
  8350.    Int_Type n, max_n;
  8351.  
  8352.  
  8353.  DESCRIPTION
  8354.   The `strreplace' function may be used to replace one or more
  8355.   occurrences of `b' in `a' with `c'.  If the integer
  8356.   `max_n' is positive, then the first `max_n' occurrences of
  8357.   `b' in `a' will be replaced.  Otherwise, if `max_n' is
  8358.   negative, then the last `abs(max_n)' occurrences will be replaced.
  8359.  
  8360.   The function returns the resulting string and an integer indicating
  8361.   how many replacements were made.
  8362.  
  8363.  EXAMPLE
  8364.   The following function illustrates how `strreplace' may be used
  8365.   to remove all occurrences of a specified substring:
  8366.  
  8367.      define delete_substrings (a, b)
  8368.      {
  8369.         (a, ) = strreplace (a, b, "", strlen (a));
  8370.         return a;
  8371.      }
  8372.  
  8373.  
  8374.  SEE ALSO
  8375.   is_substr, strsub, strtrim, strtrans, str_delete_chars
  8376.  
  8377. --------------------------------------------------------------
  8378.  
  8379. strsub
  8380.  
  8381.  SYNOPSIS
  8382.   Replace a character with another in a string.
  8383.  
  8384.  USAGE
  8385.   String_Type strsub (String_Type s, Int_Type pos, Int_Type ch)
  8386.  
  8387.  DESCRIPTION
  8388.   The `strsub' function may be used to substitute the character
  8389.   `ch' for the character at character position `pos' of the string
  8390.   `s'.  The resulting string is returned.
  8391.  
  8392.  EXAMPLE
  8393.  
  8394.     define replace_spaces_with_comma (s)
  8395.     {
  8396.       variable n;
  8397.       while (n = is_substr (s, " "), n) s = strsub (s, n, ',');
  8398.       return s;
  8399.     }
  8400.  
  8401.   For uses such as this, the `strtrans' function is a better choice.
  8402.  
  8403.  NOTES
  8404.   The first character in the string `s' is specified by `pos'
  8405.   equal to 1.  This function uses character semantics, not byte
  8406.   semantics.
  8407.  
  8408.  SEE ALSO
  8409.   is_substr, strreplace, strlen
  8410.  
  8411. --------------------------------------------------------------
  8412.  
  8413. strtok
  8414.  
  8415.  SYNOPSIS
  8416.   Extract tokens from a string
  8417.  
  8418.  USAGE
  8419.   String_Type[] strtok (String_Type str [,String_Type white])
  8420.  
  8421.  DESCRIPTION
  8422.   `strtok' breaks the string `str' into a series of tokens
  8423.   and returns them as an array of strings.  If the second parameter
  8424.   `white' is present, then it specifies the set of characters
  8425.   that are to be regarded as whitespace when extracting the tokens,
  8426.   and may consist of the whitespace characters or a range of such
  8427.   characters. If the first character of `white' is `'^'',
  8428.   then the whitespace characters consist of all characters except
  8429.   those in `white'.  For example, if `white' is `"
  8430.   \t\n,;."', then those characters specify the whitespace
  8431.   characters.  However, if `white' is given by
  8432.   `"^a-zA-Z0-9_"', then any character is a whitespace character
  8433.   except those in the ranges `a-z', `A-Z', `0-9', and
  8434.   the underscore character.  To specify the hyphen character as a
  8435.   whitespace character, then it should be the first character of the
  8436.   whitespace string.  In addition to ranges, the whitespace specifier
  8437.   may also include character classes:
  8438.  
  8439.     \w matches a unicode "word" character, taken to be alphanumeric.
  8440.     \a alphabetic character, excluding digits
  8441.     \s matches whitespace
  8442.     \l matches lowercase
  8443.     \u matches uppercase
  8444.     \d matches a digit
  8445.     \\ matches a backslash
  8446.     \^ matches a ^ character
  8447.  
  8448.  
  8449.   If the second parameter is not present, then it defaults to
  8450.   `"\s"'.
  8451.  
  8452.  EXAMPLE
  8453.   The following example may be used to count the words in a text file:
  8454.  
  8455.     define count_words (file)
  8456.     {
  8457.        variable fp, line, count;
  8458.  
  8459.        fp = fopen (file, "r");
  8460.        if (fp == NULL) return -1;
  8461.  
  8462.        count = 0;
  8463.        while (-1 != fgets (&line, fp))
  8464.          {
  8465.            line = strtok (line, "^\\a");
  8466.            count += length (line);
  8467.          }
  8468.        () = fclose (fp);
  8469.        return count;
  8470.     }
  8471.  
  8472.   Here a word was assumed to consist only of alphabetic characters.
  8473.  
  8474.  SEE ALSO
  8475.   strchop, strcompress, strjoin
  8476.  
  8477. --------------------------------------------------------------
  8478.  
  8479. strtrans
  8480.  
  8481.  SYNOPSIS
  8482.   Replace characters in a string
  8483.  
  8484.  USAGE
  8485.   String_Type strtrans (str, old_set, new_set)
  8486.  
  8487.    String_Type str, old_set, new_set;
  8488.  
  8489.  
  8490.  DESCRIPTION
  8491.   The `strtrans' function may be used to replace all the characters
  8492.   from the set `old_set' with the corresponding characters from
  8493.   `new_set' in the string `str'.  If `new_set' is empty,
  8494.   then the characters in `old_set' will be removed from `str'.
  8495.  
  8496.   If `new_set' is not empty, then `old_set' and
  8497.   `new_set' must be commensurate.  Each set may consist of
  8498.   character ranges such as `A-Z' and character classes:
  8499.  
  8500.     \w matches a unicode "word" character, taken to be alphanumeric.
  8501.     \a alphabetic character, excluding digits
  8502.     \s matches whitespace
  8503.     \l matches lowercase
  8504.     \u matches uppercase
  8505.     \d matches a digit
  8506.     \7 matches any 7bit ascii character
  8507.     \\ matches a backslash
  8508.     \^ matches a ^ character
  8509.  
  8510.   If the first character of a set is `^' then the set is taken to
  8511.   be the complement set.
  8512.  
  8513.  EXAMPLE
  8514.  
  8515.     str = strtrans (str, "\\u", "\\l");   % lower-case str
  8516.     str = strtrans (str, "^0-9", " ");    % Replace anything but 0-9 by space
  8517.     str = strtrans (str, "\\^0-9", " ");  % Replace '^' and 0-9 by a space
  8518.  
  8519.  
  8520.  SEE ALSO
  8521.   strreplace, strtrim, strup, strlow
  8522.  
  8523. --------------------------------------------------------------
  8524.  
  8525. strtrim
  8526.  
  8527.  SYNOPSIS
  8528.   Remove whitespace from the ends of a string
  8529.  
  8530.  USAGE
  8531.   String_Type strtrim (String_Type s [,String_Type w])
  8532.  
  8533.  DESCRIPTION
  8534.   The `strtrim' function removes all leading and trailing whitespace
  8535.   characters from the string `s' and returns the result.  The
  8536.   optional second parameter specifies the set of whitespace
  8537.   characters.  If the argument is not present, then the set defaults
  8538.   to `"\s"'.  The whitespace specification may consist of
  8539.   character ranges such as `A-Z' and character classes:
  8540.  
  8541.     \w matches a unicode "word" character, taken to be alphanumeric.
  8542.     \a alphabetic character, excluding digits
  8543.     \s matches whitespace
  8544.     \l matches lowercase
  8545.     \u matches uppercase
  8546.     \d matches a digit
  8547.     \\ matches a backslash
  8548.     \^ matches a ^ character
  8549.  
  8550.   If the first character of a set is `^' then the set is taken to
  8551.   be the complement set.
  8552.  
  8553.  SEE ALSO
  8554.   strtrim_beg, strtrim_end, strcompress
  8555.  
  8556. --------------------------------------------------------------
  8557.  
  8558. strtrim_beg
  8559.  
  8560.  SYNOPSIS
  8561.   Remove leading whitespace from a string
  8562.  
  8563.  USAGE
  8564.   String_Type strtrim_beg (String_Type s [,String_Type w])
  8565.  
  8566.  DESCRIPTION
  8567.   The `strtrim_beg' function removes all leading whitespace
  8568.   characters from the string `s' and returns the result.
  8569.   The optional second parameter specifies the set of whitespace
  8570.   characters.  See the documentation for the `strtrim' function
  8571.   form more information about the whitespace parameter.
  8572.  
  8573.  SEE ALSO
  8574.   strtrim, strtrim_end, strcompress
  8575.  
  8576. --------------------------------------------------------------
  8577.  
  8578. strtrim_end
  8579.  
  8580.  SYNOPSIS
  8581.   Remove trailing whitespace from a string
  8582.  
  8583.  USAGE
  8584.   String_Type strtrim_end (String_Type s [,String_Type w])
  8585.  
  8586.  DESCRIPTION
  8587.   The `strtrim_end' function removes all trailing whitespace
  8588.   characters from the string `s' and returns the result.  The
  8589.   optional second parameter specifies the set of whitespace
  8590.   characters.  See the documentation for the `strtrim' function
  8591.   form more information about the whitespace parameter.
  8592.  
  8593.  SEE ALSO
  8594.   strtrim, strtrim_beg, strcompress
  8595.  
  8596. --------------------------------------------------------------
  8597.  
  8598. strup
  8599.  
  8600.  SYNOPSIS
  8601.   Convert a string to uppercase
  8602.  
  8603.  USAGE
  8604.   String_Type strup (String_Type s)
  8605.  
  8606.  DESCRIPTION
  8607.   The `strup' function takes a string `s' and returns another
  8608.   string identical to `s' except that all lower case characters
  8609.   that contained in `s' are converted to upper case.
  8610.  
  8611.  EXAMPLE
  8612.   The function
  8613.  
  8614.     define Strcmp (a, b)
  8615.     {
  8616.       return strcmp (strup (a), strup (b));
  8617.     }
  8618.  
  8619.   performs a case-insensitive comparison operation of two strings by
  8620.   converting them to upper case first.
  8621.  
  8622.  SEE ALSO
  8623.   strlow, toupper, strcmp, strtrim, define_case, strtrans
  8624.  
  8625. --------------------------------------------------------------
  8626.  
  8627. str_delete_chars
  8628.  
  8629.  SYNOPSIS
  8630.   Delete characters from a string
  8631.  
  8632.  USAGE
  8633.   String_Type str_delete_chars (String_Type str, String_Type del_set
  8634.  
  8635.  DESCRIPTION
  8636.   This function may be used to delete the set of characters specified
  8637.   by `del_set' from the string `str'.  The result is returned.
  8638.  
  8639.   The set of characters to be deleted may include ranges such as
  8640.   `A-Z' and characters classes:
  8641.  
  8642.     \w matches a unicode "word" character, taken to be alphanumeric.
  8643.     \a alphabetic character, excluding digits
  8644.     \s matches whitespace
  8645.     \l matches lowercase
  8646.     \u matches uppercase
  8647.     \d matches a digit
  8648.     \\ matches a backslash
  8649.     \^ matches a ^ character
  8650.  
  8651.   If the first character of `del_set' is `^', then the set
  8652.   is taken to be the complement of the remaining string.
  8653.  
  8654.  EXAMPLE
  8655.  
  8656.     str = str_delete_chars (str, "^A-Za-z");
  8657.  
  8658.   will remove all characters except `A-Z' and `a-z' from
  8659.   `str'.  Similarly,
  8660.  
  8661.     str = str_delete_chars (str, "^\\a");
  8662.  
  8663.   will remove all but the alphabetic characters.
  8664.  
  8665.  SEE ALSO
  8666.   strtrans, strreplace, strcompress
  8667.  
  8668. --------------------------------------------------------------
  8669.  
  8670. str_quote_string
  8671.  
  8672.  SYNOPSIS
  8673.   Escape characters in a string.
  8674.  
  8675.  USAGE
  8676.   String_Type str_quote_string(String_Type str, String_Type qlis, Int_Type quote)
  8677.  
  8678.  DESCRIPTION
  8679.   The `str_quote_string' returns a string identical to `str'
  8680.   except that all characters contained in the string `qlis' are
  8681.   escaped with the `quote' character, including the quote
  8682.   character itself.  This function is useful for making a string that
  8683.   can be used in a regular expression.
  8684.  
  8685.  EXAMPLE
  8686.   Execution of the statements
  8687.  
  8688.    node = "Is it [the coat] really worth $100?";
  8689.    tag = str_quote_string (node, "\\^$[]*.+?", '\\');
  8690.  
  8691.   will result in `tag' having the value:
  8692.  
  8693.     Is it \[the coat\] really worth \$100\?
  8694.  
  8695.  
  8696.  SEE ALSO
  8697.   str_uncomment_string, make_printable_string
  8698.  
  8699. --------------------------------------------------------------
  8700.  
  8701. str_replace
  8702.  
  8703.  SYNOPSIS
  8704.   Replace a substring of a string (deprecated)
  8705.  
  8706.  USAGE
  8707.   Int_Type str_replace (String_Type a, String_Type b, String_Type c)
  8708.  
  8709.  DESCRIPTION
  8710.   The `str_replace' function replaces the first occurrence of `b' in
  8711.   `a' with `c' and returns an integer that indicates whether a
  8712.   replacement was made.  If `b' does not occur in `a', zero is
  8713.   returned.  However, if `b' occurs in `a', a non-zero integer is
  8714.   returned as well as the new string resulting from the replacement.
  8715.  
  8716.  NOTES
  8717.   This function has been superceded by `strreplace'.  It should no
  8718.   longer be used.
  8719.  
  8720.  SEE ALSO
  8721.   strreplace
  8722.  
  8723. --------------------------------------------------------------
  8724.  
  8725. str_uncomment_string
  8726.  
  8727.  SYNOPSIS
  8728.   Remove comments from a string
  8729.  
  8730.  USAGE
  8731.   String_Type str_uncomment_string(String_Type s, String_Type beg, String_Type end)
  8732.  
  8733.  DESCRIPTION
  8734.   This function may be used to remove simple forms of comments from a
  8735.   string `s'. The parameters, `beg' and `end', are strings
  8736.   of equal length whose corresponding characters specify the begin and
  8737.   end comment characters, respectively.  It returns the uncommented
  8738.   string.
  8739.  
  8740.  EXAMPLE
  8741.   The expression
  8742.  
  8743.      str_uncomment_string ("Hello (testing) 'example' World", "'(", "')")
  8744.  
  8745.   returns the string `"Hello   World"'.
  8746.  
  8747.  NOTES
  8748.   This routine does not handle multicharacter comment delimiters and it
  8749.   assumes that comments are not nested.
  8750.  
  8751.  SEE ALSO
  8752.   str_quote_string, str_delete_chars, strtrans
  8753.  
  8754. --------------------------------------------------------------
  8755.  
  8756. substr
  8757.  
  8758.  SYNOPSIS
  8759.   Extract a substring from a string
  8760.  
  8761.  USAGE
  8762.   String_Type substr (String_Type s, Int_Type n, Int_Type len)
  8763.  
  8764.  DESCRIPTION
  8765.   The `substr' function returns a substring with character length
  8766.   `len' of the string `s' beginning at the character position
  8767.   `n'.  If `len' is `-1', the entire length of the string
  8768.   `s' will be used for `len'.  The first character of `s'
  8769.   is given by `n' equal to 1.
  8770.  
  8771.  EXAMPLE
  8772.  
  8773.      substr ("To be or not to be", 7, 5);
  8774.  
  8775.   returns `"or no"'
  8776.  
  8777.  NOTES
  8778.   In many cases it is more convenient to use array indexing rather
  8779.   than the `substr' function.  In fact, if UTF-8 mode is not in
  8780.   effect, `substr(s,i+1,strlen(s))' is equivalent to
  8781.   `s[[i:]]'.  Array indexing uses byte-semantics, not character
  8782.   semantics assumed by the `substr' function.
  8783.  
  8784.  SEE ALSO
  8785.   is_substr, substrbytes, strlen
  8786.  
  8787. --------------------------------------------------------------
  8788.  
  8789. substrbytes
  8790.  
  8791.  SYNOPSIS
  8792.   Extract a byte sequence from a string
  8793.  
  8794.  USAGE
  8795.   String_Type substrbytes (String_Type s, Int_Type n, Int_Type len)
  8796.  
  8797.  DESCRIPTION
  8798.   The `substrbytes' function returns a substring with byte length
  8799.   `len' of the string `s' beginning at the byte position
  8800.   `n', counting from 1.  If `len' is `-1', the entire
  8801.   byte-length of the string `s' will be used for `len'.  The first
  8802.   byte of `s' is given by `n' equal to 1.
  8803.  
  8804.  EXAMPLE
  8805.  
  8806.      substrbytes ("To be or not to be", 7, 5);
  8807.  
  8808.   returns `"or no"'
  8809.  
  8810.  NOTES
  8811.   In many cases it is more convenient to use array indexing rather
  8812.   than the `substr' function.  In fact
  8813.   `substrbytes(s,i+1,-1)' is equivalent to
  8814.   `s[[i:]]'.
  8815.  
  8816.   The function `substr' may be used if character semantics are
  8817.   desired.
  8818.  
  8819.  SEE ALSO
  8820.   substr, strbytelen
  8821.  
  8822. --------------------------------------------------------------
  8823.  
  8824. __add_binary
  8825.  
  8826.  SYNOPSIS
  8827.   Extend a binary operation to a user defined type
  8828.  
  8829.  USAGE
  8830.   __add_binary(op, return_type, binary_funct, lhs_type, rhs_type)
  8831.  
  8832.    String_Type op;
  8833.    Ref_Type binary_funct;
  8834.    DataType_Type return_type, lhs_type, rhs_type;
  8835.  
  8836.  
  8837.  DESCRIPTION
  8838.   The `__add_binary' function is used to specify a function to be
  8839.   called when a binary operation takes place between specified data
  8840.   types.  The first parameter indicates the binary operator and must
  8841.   be one of the following:
  8842.  
  8843.    "+", "-", "*", "/", "==", "!=", ">", ">=", "<", "<=", "^",
  8844.    "or", "and", "&", "|", "xor", "shl", "shr", "mod"
  8845.  
  8846.   The second parameter (`binary_funct') specifies the function to
  8847.   be called when the binary function takes place between the
  8848.   types `lhs_type' and `rhs_type'.  The `return_type'
  8849.   parameter stipulates the return values of the function and the data
  8850.   type of the result of the binary operation.
  8851.  
  8852.   The data type for `lhs_type' or `rhs_type' may be left
  8853.   unspecified by using Any_Type for either of these values.
  8854.   However, at least one of the parameters must correspond to a
  8855.   user-defined datatype.
  8856.  
  8857.  EXAMPLE
  8858.   This example defines a vector data type and extends the "*" operator
  8859.   to the new type:
  8860.  
  8861.     typedef struct { x, y, z } Vector_Type;
  8862.     define vector (x, y, z)
  8863.     {
  8864.        variable v = @Vector_Type;
  8865.        v.x = x;
  8866.        v.y = y;
  8867.        v.z = z;
  8868.        return v;
  8869.     }
  8870.     static define vector_scalar_mul (v, a)
  8871.     {
  8872.        return vector (a*v.x, a*v.y, a*v.z);
  8873.     }
  8874.     static define scalar_vector_mul (a, v)
  8875.     {
  8876.        return vector_scalar_mul (v, a);
  8877.     }
  8878.     static define dotprod (v1,v2)
  8879.     {
  8880.        return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
  8881.     }
  8882.     __add_binary ("*", Vector_Type, &scalar_vector_mul, Any_Type, Vector_Type);
  8883.     __add_binary ("*", Vector_Type, &scalar_vector_mul, Any_Type, Vector_Type);
  8884.     __add_binary ("*", Double_Type, &dotprod, Vector_Type, Vector_Type);
  8885.  
  8886.  
  8887.  SEE ALSO
  8888.   __add_unary, __add_string, __add_destroy
  8889.  
  8890. --------------------------------------------------------------
  8891.  
  8892. __add_string
  8893.  
  8894.  SYNOPSIS
  8895.   Specify a string representation for a user-defined type
  8896.  
  8897.  USAGE
  8898.   __add_string (DataType_Type user_type, Ref_Type func)
  8899.  
  8900.  DESCRIPTION
  8901.   The `__add_string' function specifies a function to be called
  8902.   when a string representation is required for the specified
  8903.   user-defined datatype.
  8904.  
  8905.  EXAMPLE
  8906.   Consider the `Vector_Type' object defined in the example
  8907.   for the `__add_binary' function.
  8908.  
  8909.      static define vector_string (v)
  8910.      {
  8911.         return sprintf ("[%S,%S,%S]", v.x, v.y, v.z);
  8912.      }
  8913.      __add_string (Vector_Type, &vector_string);
  8914.  
  8915.   Then
  8916.  
  8917.      v = vector (3, 4, 5);
  8918.      vmessage ("v=%S", v);
  8919.  
  8920.   will generate the message:
  8921.  
  8922.      v=[3,4,5]
  8923.  
  8924.  
  8925.  SEE ALSO
  8926.   __add_unary, __add_binary, __add_destroy, __add_typecast
  8927.  
  8928. --------------------------------------------------------------
  8929.  
  8930. __add_typecast
  8931.  
  8932.  SYNOPSIS
  8933.   Add a typecast-function for a user-defined type
  8934.  
  8935.  USAGE
  8936.   __add_typecast (DataType_Type user_type, DataType_Type totype, Ref_Type func)
  8937.  
  8938.  DESCRIPTION
  8939.   The `__add_typecast' function specifies a function to be called
  8940.   to typecast the user-defined type to an object of type
  8941.   `totype'.  The function must be defined to take a single
  8942.   argument (the user-type to be converted) and must return an object
  8943.   of type `totype'.
  8944.  
  8945.  SEE ALSO
  8946.   __add_unary, __add_binary, __add_destroy, __add_string
  8947.  
  8948. --------------------------------------------------------------
  8949.  
  8950. __add_unary
  8951.  
  8952.  SYNOPSIS
  8953.   Extend a unary operator to a user-defined type
  8954.  
  8955.  USAGE
  8956.   __add_unary (op, return_type, unary_func, user_type)
  8957.  
  8958.    String_Type op;
  8959.    Ref_Type unary_func;
  8960.    DataType_Type return_type, user_type;
  8961.  
  8962.  
  8963.  DESCRIPTION
  8964.   The `__add_unary' function is used to define the action of an
  8965.   unary operation on a user-defined type.  The first parameter
  8966.   `op' must be a valid unary operator
  8967.  
  8968.    "-", "not", "~"
  8969.  
  8970.   or one of the following:
  8971.  
  8972.    "++", "--",
  8973.    "abs", "sign", "sqr", "mul2", "_ispos", "_isneg", "_isnonneg",
  8974.  
  8975.   The third parameter, `unary_func' specifies the function to be
  8976.   called to carry out the specified unary operation on the data type
  8977.   `user_type'.  The result of the operation is indicated by the
  8978.   value of the `return_type' parameter and must also be the
  8979.   return type of the unary function.
  8980.  
  8981.  EXAMPLE
  8982.   The example for the `__add_binary' function defined a
  8983.   `Vector_Type' object.  Here, the unary `"-"' and
  8984.   `"abs"' operators are
  8985.   extended to this type:
  8986.  
  8987.    static define vector_chs (v)
  8988.    {
  8989.       variable v1 = @Vector_Type;
  8990.       v1.x = -v.x;
  8991.       v1.y = -v.y;
  8992.       v1.z = -v.z;
  8993.       return v1;
  8994.    }
  8995.    static define vector_abs (v)
  8996.    {
  8997.       return sqrt (v.x*v.x + v.y*v.y + v.z*v.z);
  8998.    }
  8999.    __add_unary ("-", Vector_Type, &vector_chs, Vector_Type);
  9000.    __add_unary ("abs", Double_Type, &vector_abs, Vector_Type);
  9001.  
  9002.  
  9003.  SEE ALSO
  9004.   __add_binary, __add_string, __add_destroy
  9005.  
  9006. --------------------------------------------------------------
  9007.  
  9008. get_struct_field
  9009.  
  9010.  SYNOPSIS
  9011.   Get the value associated with a structure field
  9012.  
  9013.  USAGE
  9014.   x = get_struct_field (Struct_Type s, String field_name)
  9015.  
  9016.  DESCRIPTION
  9017.    The `get_struct_field' function gets the value of the field
  9018.    whose name is specified by `field_name' of the structure `s'.
  9019.  
  9020.  EXAMPLE
  9021.    The following example illustrates how this function may be used to
  9022.    to print the value of a structure.
  9023.  
  9024.       define print_struct (s)
  9025.       {
  9026.          variable name;
  9027.  
  9028.          foreach (get_struct_field_names (s))
  9029.            {
  9030.              name = ();
  9031.              value = get_struct_field (s, name);
  9032.              vmessage ("s.%s = %s\n", name, string(value));
  9033.            }
  9034.       }
  9035.  
  9036.  
  9037.  SEE ALSO
  9038.   set_struct_field, get_struct_field_names, array_info
  9039.  
  9040. --------------------------------------------------------------
  9041.  
  9042. get_struct_field_names
  9043.  
  9044.  SYNOPSIS
  9045.   Retrieve the field names associated with a structure
  9046.  
  9047.  USAGE
  9048.   String_Type[] = get_struct_field_names (Struct_Type s)
  9049.  
  9050.  DESCRIPTION
  9051.    The `get_struct_field_names' function returns an array of
  9052.    strings whose elements specify the names of the fields of the
  9053.    struct `s'.
  9054.  
  9055.  EXAMPLE
  9056.    The following example illustrates how the
  9057.    `get_struct_field_names' function may be used to print the
  9058.    value of a structure.
  9059.  
  9060.       define print_struct (s)
  9061.       {
  9062.          variable name, value;
  9063.  
  9064.          foreach (get_struct_field_names (s))
  9065.            {
  9066.              name = ();
  9067.              value = get_struct_field (s, name);
  9068.              vmessage ("s.%s = %s\n", name, string (value));
  9069.            }
  9070.       }
  9071.  
  9072.  
  9073.  SEE ALSO
  9074.   _push_struct_field_values, get_struct_field
  9075.  
  9076. --------------------------------------------------------------
  9077.  
  9078. is_struct_type
  9079.  
  9080.  SYNOPSIS
  9081.   Determine whether or not an object is a structure
  9082.  
  9083.  USAGE
  9084.   Integer_Type is_struct_type (X)
  9085.  
  9086.  DESCRIPTION
  9087.   The `is_struct_type' function returns 1 if the parameter
  9088.   refers to a structure or a user-defined type.  If the object is
  9089.   neither, 0 will be returned.
  9090.  
  9091.  SEE ALSO
  9092.   typeof, _typeof, _is_struct_type
  9093.  
  9094. --------------------------------------------------------------
  9095.  
  9096. _push_struct_field_values
  9097.  
  9098.  SYNOPSIS
  9099.   Push the values of a structure's fields onto the stack
  9100.  
  9101.  USAGE
  9102.   Integer_Type num = _push_struct_field_values (Struct_Type s)
  9103.  
  9104.  DESCRIPTION
  9105.   The `_push_struct_field_values' function pushes the values of
  9106.   all the fields of a structure onto the stack, returning the
  9107.   number of items pushed.  The fields are pushed such that the last
  9108.   field of the structure is pushed first.
  9109.  
  9110.  SEE ALSO
  9111.   get_struct_field_names, get_struct_field
  9112.  
  9113. --------------------------------------------------------------
  9114.  
  9115. set_struct_field
  9116.  
  9117.  SYNOPSIS
  9118.   Set the value associated with a structure field
  9119.  
  9120.  USAGE
  9121.   set_struct_field (s, field_name, field_value)
  9122.  
  9123.    Struct_Type s;
  9124.    String_Type field_name;
  9125.    Generic_Type field_value;
  9126.  
  9127.  
  9128.  DESCRIPTION
  9129.    The `set_struct_field' function sets the value of the field
  9130.    whose name is specified by `field_name' of the structure
  9131.    `s' to `field_value'.
  9132.  
  9133.  SEE ALSO
  9134.   get_struct_field, get_struct_field_names, set_struct_fields, array_info
  9135.  
  9136. --------------------------------------------------------------
  9137.  
  9138. set_struct_fields
  9139.  
  9140.  SYNOPSIS
  9141.   Set the fields of a structure
  9142.  
  9143.  USAGE
  9144.   set_struct_fields (Struct_Type s, ...)
  9145.  
  9146.  DESCRIPTION
  9147.   The `set_struct_fields' function may be used to set zero or more
  9148.   fields of a structure.  The fields are set in the order in which
  9149.   they were created when the structure was defined.
  9150.  
  9151.  EXAMPLE
  9152.  
  9153.     variable s = struct { name, age, height };
  9154.     set_struct_fields (s, "Bill", 13, 64);
  9155.  
  9156.  
  9157.  SEE ALSO
  9158.   set_struct_field, get_struct_field_names
  9159.  
  9160. --------------------------------------------------------------
  9161.  
  9162. ctime
  9163.  
  9164.  SYNOPSIS
  9165.   Convert a calendar time to a string
  9166.  
  9167.  USAGE
  9168.   String_Type ctime(Long_Type secs)
  9169.  
  9170.  DESCRIPTION
  9171.   This function returns a string representation of the time as given
  9172.   by `secs' seconds since 00:00:00 UTC, Jan 1, 1970.
  9173.  
  9174.  SEE ALSO
  9175.   time, strftime, _time, localtime, gmtime
  9176.  
  9177. --------------------------------------------------------------
  9178.  
  9179. gmtime
  9180.  
  9181.  SYNOPSIS
  9182.   Break down a time in seconds to the GMT timezone
  9183.  
  9184.  USAGE
  9185.   Struct_Type gmtime (Long_Type secs)
  9186.  
  9187.  DESCRIPTION
  9188.    The `gmtime' function is exactly like `localtime' except
  9189.    that the values in the structure it returns are with respect to GMT
  9190.    instead of the local timezone.  See the documentation for
  9191.    `localtime' for more information.
  9192.  
  9193.  NOTES
  9194.    On systems that do not support the `gmtime' C library function,
  9195.    this function is the same as `localtime'.
  9196.  
  9197.  SEE ALSO
  9198.   localtime, _time, mktime
  9199.  
  9200. --------------------------------------------------------------
  9201.  
  9202. localtime
  9203.  
  9204.  SYNOPSIS
  9205.   Break down a time in seconds to the local timezone
  9206.  
  9207.  USAGE
  9208.   Struct_Type localtime (Long_Type secs)
  9209.  
  9210.  DESCRIPTION
  9211.    The `localtime' function takes a parameter `secs'
  9212.    representing the number of seconds since 00:00:00, January 1 1970
  9213.    UTC and returns a structure containing information about `secs'
  9214.    in the local timezone.  The structure contains the following
  9215.    Int_Type fields:
  9216.  
  9217.    `tm_sec' The number of seconds after the minute, normally
  9218.       in the range 0 to 59, but can be up to 61 to allow for
  9219.       leap seconds.
  9220.  
  9221.    `tm_min' The number of minutes after the hour, in the
  9222.       range 0 to 59.
  9223.  
  9224.    `tm_hour' The number of hours past midnight, in the range
  9225.       0 to 23.
  9226.  
  9227.    `tm_mday' The day of the month, in the range 1 to 31.
  9228.  
  9229.    `tm_mon' The number of months since January, in the range
  9230.       0 to 11.
  9231.  
  9232.    `tm_year' The number of years since 1900.
  9233.  
  9234.    `tm_wday' The number of days since Sunday, in the range 0
  9235.       to 6.
  9236.  
  9237.    `tm_yday' The number of days since January 1, in the
  9238.       range 0 to 365.
  9239.  
  9240.    `tm_isdst' A flag that indicates whether daylight saving
  9241.       time is in effect at the time described.  The value is
  9242.       positive if daylight saving time is in effect, zero if it
  9243.       is not, and negative if the information is not available.
  9244.  
  9245.  SEE ALSO
  9246.   gmtime, _time, ctime, mktime
  9247.  
  9248. --------------------------------------------------------------
  9249.  
  9250. mktime
  9251.  
  9252.  SYNOPSIS
  9253.   Convert a time-structure to seconds
  9254.  
  9255.  USAGE
  9256.   secs = mktime (Struct_Type tm)
  9257.  
  9258.  DESCRIPTION
  9259.   The `mktime' function is essentially the inverse of the
  9260.   `localtime' function.  See the documentation for that function
  9261.   for more details.
  9262.  
  9263.  SEE ALSO
  9264.   localtime, gmtime, _time
  9265.  
  9266. --------------------------------------------------------------
  9267.  
  9268. strftime
  9269.  
  9270.  SYNOPSIS
  9271.   Format a date and time string
  9272.  
  9273.  USAGE
  9274.   str = strftime (String_Type format [,Struct_Type tm])
  9275.  
  9276.  DESCRIPTION
  9277.   The `strftime' creates a date and time string according to a
  9278.   specified format.  If called with a single argument, the current
  9279.   local time will be used as the reference time.  If called with two
  9280.   arguments, the second argument specifies the reference time, and
  9281.   must be a structure with the same fields as the structure returned
  9282.   by the `localtime' function.
  9283.  
  9284.   The format string may be composed of one or more of the following
  9285.   format descriptors:
  9286.  
  9287.        %A      full weekday name (Monday)
  9288.        %a      abbreviated weekday name (Mon)
  9289.        %B      full month name (January)
  9290.        %b      abbreviated month name (Jan)
  9291.        %c      standard date and time representation
  9292.        %d      day-of-month (01-31)
  9293.        %H      hour (24 hour clock) (00-23)
  9294.        %I      hour (12 hour clock) (01-12)
  9295.        %j      day-of-year (001-366)
  9296.        %M      minute (00-59)
  9297.        %m      month (01-12)
  9298.        %p      local equivalent of AM or PM
  9299.        %S      second (00-59)
  9300.        %U      week-of-year, first day sunday (00-53)
  9301.        %W      week-of-year, first day monday (00-53)
  9302.        %w      weekday (0-6, sunday is 0)
  9303.        %X      standard time representation
  9304.        %x      standard date representation
  9305.        %Y      year with century
  9306.        %y      year without century (00-99)
  9307.        %Z      timezone name
  9308.        %%      percent sign
  9309.  
  9310.  as well as any others provided by the C library.  The actual values
  9311.  represented by the format descriptors are locale-dependent.
  9312.  
  9313.  EXAMPLE
  9314.  
  9315.     message (strftime ("Today is %A, day %j of the year"));
  9316.     tm = localtime (0);
  9317.     message (strftime ("Unix time 0 was on a %A", tm));
  9318.  
  9319.  
  9320.  SEE ALSO
  9321.   localtime, time
  9322.  
  9323. --------------------------------------------------------------
  9324.  
  9325. _tic
  9326.  
  9327.  SYNOPSIS
  9328.   Reset the CPU timer
  9329.  
  9330.  USAGE
  9331.   _tic ()
  9332.  
  9333.  DESCRIPTION
  9334.   The `_tic' function resets the internal CPU timer.  The
  9335.  `_toc' may be used to read this timer.  See the documentation
  9336.  for the `_toc' function for more information.
  9337.  
  9338.  SEE ALSO
  9339.   _toc, times, tic, toc
  9340.  
  9341. --------------------------------------------------------------
  9342.  
  9343. tic
  9344.  
  9345.  SYNOPSIS
  9346.   Reset the interval timer
  9347.  
  9348.  USAGE
  9349.   void tic ()
  9350.  
  9351.  DESCRIPTION
  9352.   The `tic' function resets the internal interval timer.  The
  9353.  `toc' may be used to read the interval timer.
  9354.  
  9355.  EXAMPLE
  9356.   The tic/toc functions may be used to measure execution times.  For
  9357.  example, at the `slsh' prompt, they may be used to measure the speed
  9358.  of a loop:
  9359.  
  9360.    slsh> tic; loop (500000); toc;
  9361.    0.06558
  9362.  
  9363.  
  9364.  NOTES
  9365.   On Unix, this timer makes use of the C library `gettimeofday'
  9366.   function.
  9367.  
  9368.  SEE ALSO
  9369.   toc, times
  9370.  
  9371. --------------------------------------------------------------
  9372.  
  9373. _time
  9374.  
  9375.  SYNOPSIS
  9376.   Get the current calendar time in seconds
  9377.  
  9378.  USAGE
  9379.   Long_Type _time ()
  9380.  
  9381.  DESCRIPTION
  9382.   The `_time' function returns the number of elapsed seconds since
  9383.   00:00:00 UTC, January 1, 1970.  A number of functions (`ctime',
  9384.   `gmtime', `localtime', etc.) are able to convert such a
  9385.   value to other representations.
  9386.  
  9387.  SEE ALSO
  9388.   ctime, time, localtime, gmtime
  9389.  
  9390. --------------------------------------------------------------
  9391.  
  9392. time
  9393.  
  9394.  SYNOPSIS
  9395.   Return the current date and time as a string
  9396.  
  9397.  USAGE
  9398.   String_Type time ()
  9399.  
  9400.  DESCRIPTION
  9401.   This function returns the current time as a string of the form:
  9402.  
  9403.     Sun Apr 21 13:34:17 1996
  9404.  
  9405.  
  9406.  SEE ALSO
  9407.   strftime, ctime, message, substr
  9408.  
  9409. --------------------------------------------------------------
  9410.  
  9411. times
  9412.  
  9413.  SYNOPSIS
  9414.   Get process times
  9415.  
  9416.  USAGE
  9417.   Struct_Type times ()
  9418.  
  9419.  DESCRIPTION
  9420.   The `times' function returns a structure containing the
  9421.   following fields:
  9422.  
  9423.     tms_utime     (user time)
  9424.     tms_stime     (system time)
  9425.     tms_cutime    (user time of child processes)
  9426.     tms_cstime    (system time of child processes)
  9427.  
  9428.  
  9429.  NOTES
  9430.   Not all systems support this function.
  9431.  
  9432.  SEE ALSO
  9433.   _tic, _toc, _time
  9434.  
  9435. --------------------------------------------------------------
  9436.  
  9437. _toc
  9438.  
  9439.  SYNOPSIS
  9440.   Get the elapsed CPU time for the current process
  9441.  
  9442.  USAGE
  9443.   Double_Type _toc ()
  9444.  
  9445.  DESCRIPTION
  9446.   The `_toc' function returns the elapsed CPU time in seconds since
  9447.   the last call to `_tic'.  The CPU time is the amount of time the
  9448.   CPU spent running the code of the current process.
  9449.  
  9450.  NOTES
  9451.   This function may not be available on all systems.
  9452.  
  9453.   The implementation of this function is based upon the `times'
  9454.   system call.  The precision of the clock is system dependent and may
  9455.   not be very accurate for small time intervals.  For this reason, the
  9456.   tic/toc functions may be more useful for small time-intervals.
  9457.  
  9458.  SEE ALSO
  9459.   _tic, _tic, _toc, times, _time
  9460.  
  9461. --------------------------------------------------------------
  9462.  
  9463. toc
  9464.  
  9465.  SYNOPSIS
  9466.   Read the interval timer
  9467.  
  9468.  USAGE
  9469.   Double_Type toc ()
  9470.  
  9471.  DESCRIPTION
  9472.   The `toc' function returns the elapsed time in seconds since
  9473.   the last call to `tic'.  See the documentation for the
  9474.  `tic' function for more information.
  9475.  
  9476.  SEE ALSO
  9477.   tic, _tic, _toc, times, _time
  9478.  
  9479. --------------------------------------------------------------
  9480.  
  9481. atof
  9482.  
  9483.  SYNOPSIS
  9484.   Convert a string to a double precision number
  9485.  
  9486.  USAGE
  9487.   Double_Type atof (String_Type s)
  9488.  
  9489.  DESCRIPTION
  9490.   This function converts a string `s' to a double precision value
  9491.   and returns the result.  It performs no error checking on the format
  9492.   of the string.  The function `_slang_guess_type' may be used to
  9493.   check the syntax of the string.
  9494.  
  9495.  EXAMPLE
  9496.  
  9497.      define error_checked_atof (s)
  9498.      {
  9499.         if (__is_datatype_numeric (_slang_guess_type (s)))
  9500.           return atof (s);
  9501.         throw InvalidParmError, "$s is not a double"$;
  9502.     }
  9503.  
  9504.  
  9505.  SEE ALSO
  9506.   typecast, double, _slang_guess_type
  9507.  
  9508. --------------------------------------------------------------
  9509.  
  9510. atoi
  9511.  
  9512.  SYNOPSIS
  9513.   Convert a string to an integer
  9514.  
  9515.  USAGE
  9516.   Int_Type atoi (String_Type str)
  9517.  
  9518.  DESCRIPTION
  9519.   The `atoi' function converts a string to an `Int_Type'
  9520.   using the standard C library function of the corresponding name.
  9521.  
  9522.  NOTES
  9523.   This function performs no syntax checking upon its argument.
  9524.  
  9525.  SEE ALSO
  9526.   integer, atol, atoll, atof, sscanf
  9527.  
  9528. --------------------------------------------------------------
  9529.  
  9530. atol
  9531.  
  9532.  SYNOPSIS
  9533.   Convert a string to an long integer
  9534.  
  9535.  USAGE
  9536.   Long_Type atol (String_Type str)
  9537.  
  9538.  DESCRIPTION
  9539.   The `atol' function converts a string to a `Long_Type'
  9540.   using the standard C library function of the corresponding name.
  9541.  
  9542.  NOTES
  9543.   This function performs no syntax checking upon its argument.
  9544.  
  9545.  SEE ALSO
  9546.   integer, atoi, atoll, atof, sscanf
  9547.  
  9548. --------------------------------------------------------------
  9549.  
  9550. atoll
  9551.  
  9552.  SYNOPSIS
  9553.   Convert a string to a long long
  9554.  
  9555.  USAGE
  9556.   LLong_Type atoll (String_Type str)
  9557.  
  9558.  DESCRIPTION
  9559.   The `atoll' function converts a string to a `LLong_Type'
  9560.   using the standard C library function of the corresponding name.
  9561.  
  9562.  NOTES
  9563.   This function performs no syntax checking upon its argument.  Not
  9564.   all platforms provide support for the long long data type.
  9565.  
  9566.  SEE ALSO
  9567.   integer, atoi, atol, atof, sscanf
  9568.  
  9569. --------------------------------------------------------------
  9570.  
  9571. char
  9572.  
  9573.  SYNOPSIS
  9574.   Convert a character code to a string
  9575.  
  9576.  USAGE
  9577.   String_Type char (Integer_Type c)
  9578.  
  9579.  DESCRIPTION
  9580.   The `char' function converts an integer character code (ascii)
  9581.   value `c' to a string of unit character length such that the
  9582.   first character of the string is `c'.  For example,
  9583.   `char('a')' returns the string `"a"'.
  9584.  
  9585.   If UTF-8 mode is in effect  (`_slang_utf8_ok' is non-zero), the
  9586.   resulting single character may be represented by several bytes.
  9587.  
  9588.   If the character code `c' is less than 0, then byte-semantics
  9589.   will be used with the resulting string consisting of a single byte
  9590.   whose value is that of `-c&0xFF'.
  9591.  
  9592.  NOTES
  9593.   A better name should have been chosen for this function.
  9594.  
  9595.  SEE ALSO
  9596.   integer, string, typedef, sprintf, pack
  9597.  
  9598. --------------------------------------------------------------
  9599.  
  9600. define_case
  9601.  
  9602.  SYNOPSIS
  9603.   Define upper-lower case conversion
  9604.  
  9605.  USAGE
  9606.   define_case (Integer_Type ch_up, Integer_Type ch_low)
  9607.  
  9608.  DESCRIPTION
  9609.   This function defines an upper and lowercase relationship between two
  9610.   characters specified by the arguments.  This relationship is used by
  9611.   routines which perform uppercase and lowercase conversions.
  9612.   The first integer `ch_up' is the ascii value of the uppercase character
  9613.   and the second parameter `ch_low' is the ascii value of its
  9614.   lowercase counterpart.
  9615.  
  9616.  NOTES
  9617.   This function has no effect in UTF-8 mode.
  9618.  
  9619.  SEE ALSO
  9620.   strlow, strup
  9621.  
  9622. --------------------------------------------------------------
  9623.  
  9624. double
  9625.  
  9626.  SYNOPSIS
  9627.   Convert an object to double precision
  9628.  
  9629.  USAGE
  9630.   Double_Type double (x)
  9631.  
  9632.  DESCRIPTION
  9633.   The `double' function typecasts an object `x' to double
  9634.   precision.  For example, if `x' is an array of integers, an
  9635.   array of double types will be returned.  If an object cannot be
  9636.   converted to `Double_Type', a type-mismatch error will result.
  9637.  
  9638.  NOTES
  9639.   The `double' function is equivalent to the typecast operation
  9640.  
  9641.      typecast (x, Double_Type)
  9642.  
  9643.   To convert a string to a double precision number, use the `atof'
  9644.   function.
  9645.  
  9646.  SEE ALSO
  9647.   typecast, atof, int
  9648.  
  9649. --------------------------------------------------------------
  9650.  
  9651. int
  9652.  
  9653.  SYNOPSIS
  9654.   Typecast an object to an integer
  9655.  
  9656.  USAGE
  9657.   Int_Type int (s)
  9658.  
  9659.  DESCRIPTION
  9660.   This function performs a typecast of an object `s' to
  9661.   an object of Integer_Type.  If `s' is a string, it returns
  9662.   returns the ascii value of the first bytes of the string
  9663.   `s'.  If `s' is Double_Type, `int' truncates the
  9664.   number to an integer and returns it.
  9665.  
  9666.  EXAMPLE
  9667.   `int' can be used to convert single byte strings to
  9668.   integers.  As an example, the intrinsic function `isdigit' may
  9669.   be defined as
  9670.  
  9671.     define isdigit (s)
  9672.     {
  9673.       if ((int (s) >= '0') and (int (s) <= '9')) return 1;
  9674.       return 0;
  9675.     }
  9676.  
  9677.  
  9678.  NOTES
  9679.   This function is equivalent to `typecast (s, Integer_Type)';
  9680.  
  9681.  SEE ALSO
  9682.   typecast, double, integer, char, isdigit
  9683.  
  9684. --------------------------------------------------------------
  9685.  
  9686. integer
  9687.  
  9688.  SYNOPSIS
  9689.   Convert a string to an integer
  9690.  
  9691.  USAGE
  9692.   Integer_Type integer (String_Type s)
  9693.  
  9694.  DESCRIPTION
  9695.   The `integer' function converts a string representation of an
  9696.   integer back to an integer.  If the string does not form a valid
  9697.   integer, a SyntaxError will be thrown.
  9698.  
  9699.  EXAMPLE
  9700.   `integer ("1234")' returns the integer value `1234'.
  9701.  
  9702.  NOTES
  9703.   This function operates only on strings and is not the same as the
  9704.   more general `typecast' operator.
  9705.  
  9706.  SEE ALSO
  9707.   typecast, _slang_guess_type, string, sprintf, char
  9708.  
  9709. --------------------------------------------------------------
  9710.  
  9711. isdigit
  9712.  
  9713.  SYNOPSIS
  9714.   Tests for a decimal digit character
  9715.  
  9716.  USAGE
  9717.   Integer_Type isdigit (s)
  9718.  
  9719.  DESCRIPTION
  9720.   This function returns a non-zero value if the character represented
  9721.   by `s' is a digit; otherwise, it returns zero.  If `s' is
  9722.   a string, the first character of `s' will be used for the test.
  9723.  
  9724.  EXAMPLE
  9725.   A simple, user defined implementation of `isdigit' is
  9726.  
  9727.     define isdigit (x)
  9728.     {
  9729.        return ((x <= '9') and (x >= '0'));
  9730.     }
  9731.  
  9732.   However, the intrinsic function `isdigit' executes many times faster
  9733.   than the representation defined above, and works properly when
  9734.   `x' is a Unicode character.
  9735.  
  9736.  SEE ALSO
  9737.   int, integer
  9738.  
  9739. --------------------------------------------------------------
  9740.  
  9741. _slang_guess_type
  9742.  
  9743.  SYNOPSIS
  9744.   Guess the data type that a string represents
  9745.  
  9746.  USAGE
  9747.   DataType_Type _slang_guess_type (String_Type s)
  9748.  
  9749.  DESCRIPTION
  9750.   This function tries to determine whether its argument `s'
  9751.   represents an integer (short, int, long), floating point (float,
  9752.   double), or a complex number.  If it appears to be none of these,
  9753.   then a string is assumed.  It returns one of the following values
  9754.   depending on the format of the string `s':
  9755.  
  9756.     Short_Type     :  short integer           (e.g., "2h")
  9757.     UShort_Type    :  unsigned short integer  (e.g., "2hu")
  9758.     Integer_Type   :  integer                 (e.g., "2")
  9759.     UInteger_Type  :  unsigned integer        (e.g., "2")
  9760.     Long_Type      :  long integer            (e.g., "2l")
  9761.     ULong_Type     :  unsigned long integer   (e.g., "2l")
  9762.     Float_Type     :  float                   (e.g., "2.0f")
  9763.     Double_Type    :  double                  (e.g., "2.0")
  9764.     Complex_Type   :  imaginary               (e.g., "2i")
  9765.     String_Type    :  Anything else.          (e.g., "2foo")
  9766.  
  9767.   For example, `_slang_guess_type("1e2")' returns
  9768.   Double_Type but `_slang_guess_type("e12")' returns
  9769.   String_Type.
  9770.  
  9771.  SEE ALSO
  9772.   integer, string, double, atof, __is_datatype_numeric
  9773.  
  9774. --------------------------------------------------------------
  9775.  
  9776. string
  9777.  
  9778.  SYNOPSIS
  9779.   Convert an object to a string representation.
  9780.  
  9781.  USAGE
  9782.   String_Type string (obj)
  9783.  
  9784.  DESCRIPTION
  9785.    The `string' function may be used to convert an object
  9786.    `obj' of any type to its string representation.
  9787.    For example, `string(12.34)' returns `"12.34"'.
  9788.  
  9789.  EXAMPLE
  9790.  
  9791.      define print_anything (anything)
  9792.      {
  9793.         message (string (anything));
  9794.      }
  9795.  
  9796.  
  9797.  NOTES
  9798.    This function is _not_ the same as typecasting to a String_Type
  9799.    using the `typecast' function.
  9800.  
  9801.  SEE ALSO
  9802.   typecast, sprintf, integer, char
  9803.  
  9804. --------------------------------------------------------------
  9805.  
  9806. tolower
  9807.  
  9808.  SYNOPSIS
  9809.   Convert a character to lowercase.
  9810.  
  9811.  USAGE
  9812.   Integer_Type lower (Integer_Type ch)
  9813.  
  9814.  DESCRIPTION
  9815.   This function takes an integer `ch' and returns its lowercase
  9816.   equivalent.
  9817.  
  9818.  SEE ALSO
  9819.   toupper, strup, strlow, int, char, define_case
  9820.  
  9821. --------------------------------------------------------------
  9822.  
  9823. toupper
  9824.  
  9825.  SYNOPSIS
  9826.   Convert a character to uppercase.
  9827.  
  9828.  USAGE
  9829.   Integer_Type toupper (Integer_Type ch)
  9830.  
  9831.  DESCRIPTION
  9832.   This function takes an integer `ch' and returns its uppercase
  9833.   equivalent.
  9834.  
  9835.  SEE ALSO
  9836.   tolower, strup, strlow, int, char, define_case
  9837.  
  9838. --------------------------------------------------------------
  9839.  
  9840. typecast
  9841.  
  9842.  SYNOPSIS
  9843.   Convert an object from one data type to another.
  9844.  
  9845.  USAGE
  9846.   typecast (x, new_type)
  9847.  
  9848.  DESCRIPTION
  9849.   The `typecast' function performs a generic typecast operation on
  9850.   `x' to convert it to `new_type'.  If `x' represents an
  9851.   array, the function will attempt to convert all elements of `x'
  9852.   to `new_type'.  Not all objects can be converted and a
  9853.   type-mismatch error will result upon failure.
  9854.  
  9855.  EXAMPLE
  9856.  
  9857.     define to_complex (x)
  9858.     {
  9859.        return typecast (x, Complex_Type);
  9860.     }
  9861.  
  9862.   defines a function that converts its argument, `x' to a complex
  9863.   number.
  9864.  
  9865.  SEE ALSO
  9866.   int, double, typeof
  9867.  
  9868. --------------------------------------------------------------
  9869.  
  9870. _typeof
  9871.  
  9872.  SYNOPSIS
  9873.   Get the data type of an object
  9874.  
  9875.  USAGE
  9876.   DataType_Type _typeof (x)
  9877.  
  9878.  DESCRIPTION
  9879.   This function is similar to the `typeof' function except in the
  9880.   case of arrays.  If the object `x' is an array, then the data
  9881.   type of the array will be returned. otherwise `_typeof' returns
  9882.   the data type of `x'.
  9883.  
  9884.  EXAMPLE
  9885.  
  9886.     if (Integer_Type == _typeof (x))
  9887.       message ("x is an integer or an integer array");
  9888.  
  9889.  
  9890.  SEE ALSO
  9891.   typeof, array_info, _slang_guess_type, typecast
  9892.  
  9893. --------------------------------------------------------------
  9894.  
  9895. typeof
  9896.  
  9897.  SYNOPSIS
  9898.   Get the data type of an object
  9899.  
  9900.  USAGE
  9901.   DataType_Type typeof (x)
  9902.  
  9903.  DESCRIPTION
  9904.   This function returns the data type of `x'.
  9905.  
  9906.  EXAMPLE
  9907.  
  9908.   if (Integer_Type == typeof (x)) message ("x is an integer");
  9909.  
  9910.  
  9911.  SEE ALSO
  9912.   _typeof, is_struct_type, array_info, _slang_guess_type, typecast
  9913.  
  9914. --------------------------------------------------------------
  9915.